more random.cgi lets you look at the file named random.cgi pico random.cgi would let you open file named random.cgi in the pico editor. cat random.cgi would let you look at the file random.cgi but not one screenfull at a time... more random.cgi gives you "more" control, so spacebar or Enter can be used to see next line or next screenfull of lines. cat -vet random.cgi would let you look at the file random.cgi and also see all of the INVISIBLE characters, such as LINE FEEDS and Carriage Returns. If cat -vet random.cgi shows you ^M you have TROUBLE! cat -vet random.cgi shows you only $ at the end of each line, your file is just fine, no problem. ^M is the problem, as that is an extra WINDOWS character, depending on what software you used.
The above screen snapshot of an ssh secure shell session shows the cat -vet random.cgi command followed by the output. All of the ^M have to be removed! The $ you see are OKAY! ^M ^M$ the $ is okay, but the ^M has to be removed. ^M$ $ ^M is an unprintable character. Your PERL CGI script program will NOT work on sunny.uni.edu server if it has the ^M characters embedded in it. IT APPEARS THAT IF YOU JUST OPEN UP YOUR FILE IN THE PICO EDITOR, and then make some change anywhere and SAVE THE CHANGED FILE, the ^M windows characters will all be removed. pico random.cgi would open up the file named random.cgi in the pico editor.
You can use the NOTEPAD editor, which is part of the Accessories group on Windows. You might want to use the pico editor, which is the easiest text editor to use on sunny.uni.edu computer system. Control-X and Control-O are the only commands you will need to use on the pico editor. ^X Exit ^O WriteOut If you wish to COPY something from a PDF file or from your Notepad .TXT file, you can PASTE it into the pico editor file by pulling down the EDIT menu and doing PASTE. Shift + Insert is the shortcut. VIP: Control+V is NOT the keyboard shortcut for PICO editor Pasting! pico random.cgi would create the file named random.cgi or would open up the existing file random.cgi for further editing, if it already existed. pico quote8.txt creates a new file quote8.txt or edits the existing file quote8.txt, that is found in the current directory.
chmod 755 random.cgi bash-2.03$ ls -l rand.cgi -rwxr-xr-x 1 jacobson faculty 548 Apr 24 11:04 rand.cgi rwx r-x r-x 111101101 111 101 101 755 permissions include eXecute 7 5 5 bash-2.03$ chmod 644 rand.cgi bash-2.03$ ls -l rand.cgi -rw-r--r-- 1 jacobson faculty 548 Apr 24 11:04 rand.cgi rw- r-- r-- 644 permissions DO NOT INCLUDE eXecute 110100100 110 100 100 which PERL CGI scripts REQUIRE to work! 6 4 4 bash-2.03$ chmod 755 rand.cgi bash-2.03$ ls -l rand.cgi -rwxr-xr-x 1 jacobson faculty 548 Apr 24 11:04 rand.cgi
#!/usr/bin/perl <--- IS OKAY #!/usr/bin/perl print "Content-type: text/html\n\n"; WILL NOT WORK! print "Content-type: text/html\n\n";
bash-2.03$ perl rand.cgi <------ Run the perl program on your .cgi file, for example rand.cgi here. Content-type: text/html -------- the 3rd line of output of your perl script ... ... ... OR YOU MIGHT FIND OUT YOU HAVE A SYNTAX ERROR IN YOUR PERL script (program). bash-2.03$ perl rand.cgi syntax error at rand.cgi line 4, near "print" Execution of rand.cgi aborted due to compilation errors. I removed the semicolon from the end of line #3 to cause this error message in rand.cgi file. print "Content-type: text/html\n\n" is wrong because of missing ; PERL sees there is a problem when it gets to the word print on the next line, on the 4th line of the rand.cgi file. print "Content-type: text/html\n\n"; is correct version...
@quotes = ("snowball.txt", "quote2.txt", "quote1.txt", "quote4.txt", "nemo.txt", "quote6.txt", "surfsUp.txt", "quote8.txt", "quote9.txt");
bash-2.03$ ls <---ls to LiSt the contents of the cgi folder Ghostbusters_cover.png quote5.txt random2.cgi Surfs_up.jpg quote6.txt snowball.txt nemo.txt quote7.txt surfsUp.txt quote1.txt quote8.txt tryPerl.cgi quote2.txt quote9.txt tryperl.cgi quote3.txt rand.cgi quote4.txt random.cgi www.uni.edu/jacobson/cgi/rand.cgi --- -------- cd cgi to move down into the folder named cgi bash-2.03$ pwd pwd show path of working directory /export/home/jacobson/cgi - - - p w d bash-2.03$ cd .. .. refers to the PARENT directory cd .. changes directory to the parent folder. bash-2.03$ pwd /export/home/jacobson bash-2.03$ cd cgi cd cgi is change directory to the directory named cgi, i.e. move down into the cgi folder, open the cgi folder. bash-2.03$ pwd /export/home/jacobson/cgi <----- See that we are now inside that folder (cgi) Question to find the answer for: What would be output right now if I do the following command? ls .. What would be output right now if I do the following command? ls -l LS minus L or LS hyphenL for ls -l