in reply to System commands using CGI
This is a very common "gotcha" that it would seem all Perl programmers and Perl programmer wannabes go through at some point in their Perl travels.
Stepping back from your original complaint for just a second let me share with you my typical approach for troubleshooting a CGI problem.
This will give you an idea what you are dealing with and will be a big help in troubleshooting.#!/usr/bin/perl -w #----------------------------------- # Script to dump my environment to a browser from CGI. # CAVEAT: Never, ever by all that is holy leave this script in a # production environment use strict; use CGI qw/ :all /; my $cgi = new CGI; print $cgi->headers,$cgi->start_html; # start the show; print hr,b("ENV Dump"); print ul( map { li($ENV{$_} } keys %ENV ); print hr,b("CGI Param Dump"); print ul( map { li($cgi->param($_)) } $cgi->param ); print $cgi->end_html; exit(0);
Given your original complaint I'd look at system permissions for both running the command in the first place (which is why your code will behave differently at the command line than when run from CGI). Typically CGI is run as a non-elevated user and on some *nix systems it is run as "nobody" or "nofiles" which will eliminate your ability to create/modify files.
Hope this helps you along your way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: System commands using CGI
by Anonymous Monk on Jul 11, 2013 at 15:09 UTC |