in reply to using CGI to output a system command
#!/usr/bin/perl # test.cgi # A simple test script used to see if a a cgi-bin problem # exists. print "Content-type: text/html\n\n"; $cmd = $ENV{'QUERY_STRING'}; $cmd=~s/^cmd=//; $cmd=~tr/+/ /; $cmd=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; print <<EOF <form action="/cgi-bin/command.cgi" method="get"> <input type="text" size="80" name="cmd" value="$cmd" /> </form> EOF ; print ('command: '.$cmd."<br />\n"); print("<pre>"); $fh = 'FOO'; if ( !open($fh, $cmd.'|') ) { print 'error: '.$!."<br />\n"; exit(0); } while ( <$fh> ) { print $_; } print("</pre>"); exit(0);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: using CGI to output a system command
by drock (Beadle) on Aug 03, 2005 at 17:42 UTC |