1. What should the permissions be for the cgi-bin folder? chmod 711 cgi-bin <----- drwxr-xr-x 111001001 7 1 1 Octal 711 7=111 1=001 rwx --x 2. What should the permissions be for my web folder and my home directory, and how do I set them. chmod 711 ~ <---- Done ONCE this semester chmod 711 web <---- Done ONCE this semester chmod 711 cgi-bin <---- Done ONCE this semester Note: You would have to do the following BEFORE doing the chmod 711 cgi-bin: cd web chmod 711 cgi-bin You created cgi-bin with the mkdir command, but you did that AFTER you were in the web folder. cd web mkdir cgi-bin 3. What should the permissions be for any of my .cgi perl scripts? chmod 755 *.cgi chmod 755 colors.cgi <--- Must be inside your cgi-bin folder! 4. How can I find out if there are any syntax errors in my PERL script? At the cowboy command prompt, inside of the folder where you have been working on the cgi program, type (if its called colors.cgi) ---------- perl -w colors.cgi perl colors.cgi <------ will give you some of the errors. perl -w colors.cgi <--- will possibly give you additional -warnings. 5. How can I find the line number I am on in the pico editor, to be sure I am at the line where the perl program told me there was an error? Use Control+C inside pico. ^C Cur Pos tells you the Cursor Position. --- --- 6. What permission is needed for ALL of my .gif and .jpg and .htm and .html files? chmod 644 myColorForm.html <--- For example chmod 644 sept28.html The exception here would be a guestBook.html file, that you wanted to have users be able to add their new FORM submitted information to. If your PERL CGI script to write their answers and SUBMITted data to that guestBook.html, it needs to be: chmod 766 guestBook.html -rwxrw-rw- 7 6 6 chmod 777 guestBook.html would be OK too. 7. What is the URL that I would use to get to the file named myFirstForm.html? http://student.cns.uni.edu/~yourUNI_UserID/myFirstForm.html Notice that you NEVER mention the web folder in the URL. Know also that the cns stands for college of natural sciences - - - 8. What should be the 1st 3 lines of my PERL scripts? #!/usr/bin/perl -------------------- require "subparseform.lib"; <----- OUT OF DATE use CGI ':standard'; &Parse_Form; -------------------- use CGI ':standard'; -------------------- 9. What should be the permissions for the subparseform.lib file? chmod 755 subparseform.lib <--- OUT OF DATE use CGI ':standard'; to replace this subparseform.lib 10. Where should the subparseform.lib file be located? The subparseform.lib library file should be stored in <-- OUT OF DATE your cgi-bin folder. (NOT NEEDED now with CGI.pm built into PERL). 11. What would happen if the first command you typed after logging into cowboy.cns.uni.edu were chmod 755 subparseform.lib? -------------------------- ERROR MESSAGE (actual) cowboy:~$ chmod 755 subparseform.lib chmod: WARNING: can't access subparseform.lib You forgot to do these two commands: cd web <---- Go to dining room (off living room) cd cgi-bin <---- Go to kitchen (its off dining room) You are in the living room trying to open the oven or refrigerator door. You gotta go to the kitchen first, if you want to cook supper! 12. What does cd mean? What does cd .. mean? -- ----- cd means change directory cd .. <-- means change to parent - - directory, closing current directory (folder). 13. What if you logged in to work on cowboy.cns.uni.edu, and were continuing work on yourFirstForm.html web page, and discovered it was empty? pico yourFirstForm.html <---- You discover its a brand new file!! :-( The cause of this slimer is simple. You are NOT in the right folder (directory). You need to AT LEAST type cd web, if it was stored in the web folder. If it was stored in your cgi-bin folder, inside your web folder, you need to do: cd web cd cgi-bin <--- To move down to right room-full of files. To see the names of all the files in the current folder, type: ls list files - - To see the names of all of the .html files only, type: ls *.html ( or ls *.htm* ) --------- --------- 14. How can I see what the permissions are for my files and folders? ls -l (list files long listing) LS minusL ls -l - - - ----- 15. 1111 = 15 = F = 17 Binary, Decimal, Hexadecimal, Octal 2 10 16 8 16. 10000 = 16 = 10 = 20 2 10 16 8 Base 2, Base 10, Base 16, Base 8 review 17. What error does the following PERL program contain? #!/usr/bin/perl print "Content-type:text/html\n\n"; print "Hello World PERL/CGI for 810:022 \n"; print "\n\n"; print "

\n\nHello World in cgi-bin!\n
" print "by M Jacobson\n

\n"; print "\n\n\n"; It is missing a SEMICOLON on number six (line 6). --------------------------------------------------------------------------- 17a. What USELESS error message would you see if you executed the script from a web browser? --------------------------------------------------------------------------- Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. --------------------------------------------------------------------------- 17b. What USEFUL error message do you get when you execute the script from the cowboy command prompt, using perl -w? --------------------------------------------------------------------------- cowboy:~/web/cgi-bin$ perl -w myPerl.cgi syntax error at myPerl.cgi line 7, near "print" Execution of myPerl.cgi aborted due to compilation errors. Note: The missing semicolon on line 6 causes the compiler to discover a problem on line 7, the NEXT LINE after it. ---------------------------------------------------------------------------- 18. What will be the BGCOLOR (BackGround COLOR) of the web page generated by myPerl.cgi script (see #17 above). print "\n\n"; RRGGBB Red=FF,Green=FF,Blue=00 R=255, G=255, B=0 It will be YELLOW, because RED plus GREEN equals YELLOW. 19. What would be the error in the following myPerl.cgi script? #!/usr/bin/perl print "Content-type:text/html\n\n"; print "Hello World\n"; print " \n\n"; print "

\n\nHello World!\n
; print "\n\n\n"; The ERROR is caused by a missing double quote on line #6, no closing " on this line: print "

\n\nHello World!\n
; ^ ^ " opening " quote missing quote! ----------------------------------------------------------------------------- Here is what the error message(s) looks like. Very intimidating and confusing error message, but a very simple cause. For every opening ", you need a matching closing ", is simple rule. ----------------------------------------------------------------------------- Bareword found where operator expected at myPerl2.cgi line 7, near "/BODY>\n \n\n\nHello World!\n
" ; ^ <---- SOLVED with " character! :-) ----------------------------------------------------------------------------- 20. You need to have the #!/usr/bin/perl on the 1st line of the .cgi file. --------------- -------- 21. When you run your perl program from cowboy by typing: perl -w myPerl.cgi <---- to test the syntax or ./myPerl.cgi <---- to test the eXecute permissions, and the #!/usr/bin/perl line for correctness, this is normal and OK: ----------------- cowboy:~/web/cgi-bin$ perl -w menus.cgi -w means give extra warnings ----------------- - Content-type: text/html

Use Post or GetContent-type:text/html Use of uninitialized value at menus.cgi line 10. Color is Use of uninitialized value at menus.cgi line 13. <---- WARNING :-) Use of uninitialized value at menus.cgi line 17. Use of uninitialized value at menus.cgi line 21. <---- **OUT OF DATE** Use of uninitialized value at menus.cgi line 25. CGI.pm is GREAT! Use of uninitialized value at menus.cgi line 29. <---- There was NO Use of uninitialized value at menus.cgi line 33.

submitted Use of uninitialized value at menus.cgi line 37. data from a Use of uninitialized value at menus.cgi line 41. browser....

RGB triplet was: ABCDEF

Use of uninitialized value at menus.cgi line 82. <---- Warnings are OK! ------------------------------------------------------------------------------ -------------- cowboy:~/web/cgi-bin$ perl menus.cgi <--- You do NOT get it without -w -------------- as in: perl -w menus.cgi Content-type: text/html

Use Post or GetContent-type:text/html Color is

RGB triplet was: ABCDEF

22. Pages 212-213 of the Elizabeth Castro textbook have a list of suggestions for debugging a PERL/CGI script. Be sure to study over and utilize that list of 14 things to think about when trying the debug your PERL errors. (PAGES 278 and 279 in 2nd edition) -------------------------------- Many of the above PERL FAQ suggestions from this page will be reiterated there and in chapter 15 (Debugging) of the PERL and CGI For the World Wide Web textbook. 23. I have just completed my guestBook. All of the links and such work, but when i click submit my entry and it goes to the page where it shows the messages.... the new message doesn't show up!!! Does your file with the guestbook entries in it have: as the 1st and only thing on that line, without any spaces after the > in the ^ ^--- Nothing here |_____ column #1 after the > Are the permissions for the file chmod 766 or chmod 777 for the file that is receiving new guestbook entries and which is being opened for OUTPUT and being written to while your PERL script is running? ls -l will tell you the permissions. list file -long - - - ls -l ls -l *.cgi ls -l *.lib ls -l *.html Are you using http://student.cns.uni.edu/!yourID/restOfPathTo.htmlFile? ------- henon.cns.uni.edu henon GOOD! ----- or student.cns.uni.edu student GOOD! ------- will work... www.cns.uni.edu www wrong! --- will NOT work!! ----- NO! BAD URL, for certain cgi programs. ------- ------------------- Get used to student.cns.uni.edu URL! ------------------- 24. How can I run and test a PERL statement or technique from the command line on cowboy? By using the perl -e option. ------- Here are 3 examples: cowboy:~$ perl -e 'print "\nHello\nHello\nHello!\n\n";' Hello Hello Hello! cowboy:~$ perl -e '$b16 = sprintf "%1x",175; $b16 = uc $b16; print "\n$b16\n\n";' AF cowboy:~$ perl -e '$b16 = sprintf "%1x",41; $b16 = uc $b16; print "$b16";' 29. Posted: July 12th, 2001 Thursday Very subtle error when using CGI gw(:standard) functions.... #!/usr/bin/perl -w use CGI ':standard'; print header, print start_html, h1("Hello World"), end_html; Here is the command line output of the above Perl script. cowboy:~/web/cgi-bin$ perl slimer.cgi (offline mode: enter name=value pairs on standard input) Untitled Document

Hello World

Content-Type: text/html ********** Notice where Content-Type: text/html is???? !!!! ******* ----------------------- How do you correct the above program? The problem is the comma instead of the semicolon #!/usr/bin/perl -w after print header, ------------ use CGI ':standard'; print header, start_html, # REMOVE THE print from this 2nd line h1("Hello World"), end_html; OOOO RRRR O O R R print header: O O RRRR # add a semicolon ; print start_html, O O RR after print header; h1("Hello World"), O O R R and remove the comma! end_html; OOOO R R Here is what the output looks like AFTER either above correction: cowboy:~/web/cgi-bin$ perl slimer.cgi (offline mode: enter name=value pairs on standard input) Content-Type: text/html <------ THAT IS MORE LIKE IT!!!!!! Untitled Document

Hello World