whitdan has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
I need some advice with system calls. I have been researching for the past few days and have not been able to find what I'm looking for. I'm running a Perl CGI script from a webpage that needs to make some system calls. I'm running into a problem where no system calls will work at all. Not even a simple one such as "ls". Here's the important part of the code:
#! /usr/bin/perl -T use strict; use warnings; $ENV{"PATH"} = ""; chdir "/home/user/"; chomp($update_location); # $update_location is: # /home/user/test/update_test.pl # it's retrieved from the database my $cmd = sprintf("perl %s", $update_location); system($cmd); if ($? == -1) { logger("failed to execute: $!\n"); # logger is a simple sub that appends whatever is passed # to an error.txt file } elsif ($? & 127) { logger("child died with signal coredump\n"); } else { my $sys_code = $? >> 8; logger("child exited with value $sys_code\n"); }
When I run the code above, my error.txt file says "failed to execute: Permission denied". When I comment out the chdir line, error.txt says "failed to execute: No such file or directory".
Whether or not I comment out the chdir line, if I try a simple system call such as:
it responds with "failed to execute: No such file or directory".
Permissions are
/home/ drwxr-xr-x
/home/user/ drwxr-xr-x
/home/user/test/ drwxr-xr-x
/home/user/test/update_test.pl -rwxr-xr-x
I already ran chmod +x on update_test.pl and am able to run it from a terminal.
Any ideas as to why the system calls won't work? Thank you for any advice you can give me!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: System calls from CGI script
by Corion (Patriarch) on Nov 04, 2016 at 17:31 UTC | |
by whitdan (Initiate) on Nov 04, 2016 at 19:26 UTC | |
|
Re: System calls from CGI script
by haukex (Archbishop) on Nov 04, 2016 at 17:35 UTC | |
by whitdan (Initiate) on Nov 04, 2016 at 19:36 UTC | |
|
Re: System calls from CGI script
by shmem (Chancellor) on Nov 04, 2016 at 23:52 UTC |