Connecting Tech Pros Worldwide Forums | Help | Site Map

Some commands execute via PHP "system", some don't--why?

Acrobatic
Guest
 
Posts: n/a
#1: Nov 18 '06
Hello

I've got a simple Perl script that works fine from the command line but
not from PHP via the browser. It's a conversion program that converts
an image to a different format, and writes the new image to a
directory.

I'm running as user "nobody" and have the target directory set to
"nobody:nobody", and I've tried chmodding the directory to both 755 and
777 with no luck. If I run my script from the command line, it executes
with no problems. In PHP, I'm using
"system('/dir/to/file/convert.pl',$retval)", but the file doesn't get
created.

$retval returns a 0, so I'm assuming that's a good thing.

In my Perl script, I added a generic "print "Hello, World"" to it, and
$retval then returns "Hello World0", so I know the script is at least
doing something.

Any ideas on something I'm missing? Thanks for any help or pointing in
the right direction


petersprc
Guest
 
Posts: n/a
#2: Nov 18 '06

re: Some commands execute via PHP "system", some don't--why?


Hi,

Maybe stderr has additional info? Maybe this can get more info:

exec('/dir/to/file/convert.pl 2>&1', $output, $exitCode);

if ($exitCode != 0) {
trigger_error("Command failed with exit code $exitCode: \"" .
join("\n", $output) . "\".");
}

Acrobatic wrote:
Quote:
Hello
>
I've got a simple Perl script that works fine from the command line but
not from PHP via the browser. It's a conversion program that converts
an image to a different format, and writes the new image to a
directory.
>
I'm running as user "nobody" and have the target directory set to
"nobody:nobody", and I've tried chmodding the directory to both 755 and
777 with no luck. If I run my script from the command line, it executes
with no problems. In PHP, I'm using
"system('/dir/to/file/convert.pl',$retval)", but the file doesn't get
created.
>
$retval returns a 0, so I'm assuming that's a good thing.
>
In my Perl script, I added a generic "print "Hello, World"" to it, and
$retval then returns "Hello World0", so I know the script is at least
doing something.
>
Any ideas on something I'm missing? Thanks for any help or pointing in
the right direction
C.
Guest
 
Posts: n/a
#3: Nov 19 '06

re: Some commands execute via PHP "system", some don't--why?


Acrobatic wrote:
Quote:
>
I've got a simple Perl script that works fine from the command line but
not from PHP via the browser. It's a conversion program that converts
an image to a different format, and writes the new image to a
directory.
>
Is your webserver chrooted?
Does your webserver user have permission to run the Perl executable?
Read the Perl source files?
Read the source images?

HTH

C.

Acrobatic
Guest
 
Posts: n/a
#4: Nov 20 '06

re: Some commands execute via PHP "system", some don't--why?


Hello

Thanks very much for the response--I was unaware of the 2>&1 option and
it's really helped me debug this thing. It was a permissions issue, but
I wasn't able to figure that out without your help--thanks again

Jeff


petersprc wrote:
Quote:
Hi,
>
Maybe stderr has additional info? Maybe this can get more info:
>
exec('/dir/to/file/convert.pl 2>&1', $output, $exitCode);
>
if ($exitCode != 0) {
trigger_error("Command failed with exit code $exitCode: \"" .
join("\n", $output) . "\".");
}
Closed Thread