
Help, shell commands not working from within script
: I have a script that I just wrote, and here is my problem. Within the perl
: script I do a system("whatever command"); I have also tried using a back
: quote. This works great as long as I am running it from within the unix
: command prompt. However, it never returns anything if it is from a web
: page call.
: Actually, I have noticed that the command never even gets executed. I
: tried just doing a touch on a non-existent file, and it never gets created
: (unless I run it direct from within unix).
: Any help would be GREATLY appreciated.
^^^^^^^^
Perl FAQ, part 9, the very first Frequently Asked Question:
-------------------------
=head2 My CGI script runs from the command line but not the browser. Can you help me fix it?
Sure, but you probably can't afford our contracting rates :-)
Seriously, if you can demonstrate that you've read the following FAQs
and that your problem isn't something simple that can be easily
answered, you'll probably receive a courteous and useful reply to your
question if you post it on comp.infosystems.www.authoring.cgi (if it's
something to do with HTTP, HTML, or the CGI protocols). Questions that
appear to be Perl questions but are really CGI ones that are posted to
comp.lang.perl.misc may not be so well received.
The useful FAQs are:
http://www.*-*-*.com/
http://www.*-*-*.com/
http://www.*-*-*.com/
http://www.*-*-*.com/
http://www.*-*-*.com/
-------------------------
All that help available for your problem. And it is not even
a Perl problem. It is a CGI problem. You should consider using
the CGI newsgroup for asking CGI questions:
comp.infosystems.www.authoring.cgi
Several possible problems are presented in the FAQs above.
1) did you check the return code from the system command?
if (system("whatever command")) {
warn "Uh oh! Something went wrong. $! \n";
}
2) did the user that the CGI script runs as (often 'nobody') have
the appropriate permissions for files and directories?
3) did you use the complete path to the commands?
/usr/local/bin/whatever
: Thanks,
And thank you for doing your part to ensure that the 'F' in FAQ
remains accurate ;-)
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming