473,382 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

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

Nov 18 '06 #1
3 1516
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:
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
Nov 18 '06 #2
C.
Acrobatic wrote:
>
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.

Nov 19 '06 #3
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:
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) . "\".");
}
Nov 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yawnmoth | last post by:
i know that system commands can be run using the system("command") function, but... some commands, such as mysqldump, require additional input - input that can't be entered through the command...
1
by: melanieab | last post by:
Hi, I'm having a hard time understanding why some commands appear to be ignored during an event. I have a group of tabpages, and when one tabpage is left, I have a Focus Leave event that captures...
5
by: Doogie | last post by:
Hi, I have a lot of old VB 6 experience and for the last several years have been programming in C#. Now I'm going to be doing some VB.NET development. As I'm "relearning" things so to speak, I...
5
by: pbd22 | last post by:
Hi. Anybody know of any good code examples out there on how to take a telnet command and parse it? Thanks!
1
by: Riccardo Maria Bianchi | last post by:
Hello! :) I'm trying to run shell commands both with os.system() and subprocess.Popen() class. But I can't run aliases or function defined in my .bashrc file, like in the login interactive...
21
by: poolboi | last post by:
hi guys, a question on net::telnet what does this module do? cos i have a telnet client that will be able to communicate with a database so is it true if i enter my ip address, username, and...
7
by: gert | last post by:
This works but after the su command you have to wait like 2 minutes before each command gets executed ? What did i do wrong ? import pxssh try: s = pxssh.pxssh() s.login ('127.0.0.1',...
0
by: Greenwood | last post by:
Hi all, I have a issue, a have a textbox which takes commands, the commands can be something like: rp73{ rp36 {av 14, td 10} , td 35, cc -1 1 -2 }; I have the code below so far and cant...
0
Chrisjc
by: Chrisjc | last post by:
Good evening, I am trying to figure out a way where once I connect a removable hard drive with in the “Autorun.inf” file I would like it to do the following. Check to see which “Server it is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.