I'm trying to run ssh
, mkdir
from a Perl CGI script. It's not working. But in normal Perl script, it is working fine. Can any one tell me how to run commands in a Perl CGI script?
1
votes
3 Answers
7
votes
If you're running this script via a webserver, chances are the active user (e.g. "nobody", "www", etc) may not have the necessary privileges to execute commands like mkdir
and ssh
. If so, that is not something that perl can fix. You can test who the active user is with something like:
print "The active user is: ", `whoami`;
It is also a security concern, to have your web user privileges set to create files and perform commands.
0
votes
0
votes
Do you need to run unix commands? Perl has a built-in mkdir, and there are modules to handle SSH. Normally a CGI process is going to have limited capabilities or access to the system. The more you can do in Perl the better.
$!
)? – Egga Hartungsystem
does not capture stdout. If you see it "working" when trying the script in bash, it's because you see the stdout in the background of the perl process, printed to the terminal. This data is not available to perl, and probably won't be to the webserver either. Useqx()
or backticks to capture stdout. – TLP