Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Printing a command's output (CGI)
Name: Edwards Date: April 18, 2003 at 19:10:54 Pacific OS: Red Hat 8.0 CPU/Ram: PII-350/256MB
Comment:
I want a script that'll print the output of a certain command (fortune homer). I can't get the script to print the output, and I'm not sure if it's being run at all. My more recent attempts end with this wonderful error: (in error_log) Premature end of script headers: homer.cgi (in access_log) "GET /cgi-bin/homer.cgi HTTP/1.1" 500 656
Name: Dlonra Date: April 19, 2003 at 16:17:31 Pacific
Reply:
what do you get with ./homer.cgi?
google cgi tutorial
0
Response Number 2
Name: Edwards Date: April 19, 2003 at 19:57:12 Pacific
Reply:
When I run homer.cgi, I get a 500 Internal Server Error... more info available in the log. I've googled, but haven't found anything about running commands and printing their output. The closest I've found is printing a line from a file.
0
Response Number 3
Name: Edwards Date: April 19, 2003 at 20:11:40 Pacific
Reply:
It works! I modified a ping script I found so that instead of running ping $dest, it runs fortune $file (where $file is defined within the script as homer), and IT WORKS!
I wonder if I can mod it so that $file can be defined in the URL...?
0
Response Number 4
Name: 3Dave Date: April 22, 2003 at 06:37:25 Pacific
Reply:
Not sure what language you are using, but in perl: print "$variable"; output: value print '$variable'; output: $variable print `uname -o`; output: GNU/Linux
Notice the three different quotes ( " ' ` ), for normal use, literal printing (ie doesn't evaluate variables etc) and te last for printing commands to the operating system. If the command produces an output to stdout, it is returned and printed.
It is often useful to enclose these command outputs within html {pre} and {/pre} tags which keep the formatting of the text.
Summary: That is the answer. > redirects a command's output to the named file. If the named file already exists, it is overwritten. If the named file does not exist, it is created. >> also redirects a command'...
Summary: I have two files that are several Gigs each. Need to compare the two and output the differneces when I run: diff fileA fileB > diffAB I get running out of memory. How can I run a command to output dif...