Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

system() does not execute command 1

Status
Not open for further replies.

flubbard

Technical User
Jun 11, 2003
148
US
I would like my script to make a call to a host stored program. The program is one which I have written can compiled and runs fine from the command line. However, when passed through the system() call, I get nothing back. The relevant portion of code looks like this:
Code:
if ($generate)
{
	$command = "myexecutable";
	echo system($command, $return_val) . "<br>";
	echo $return_val; 
}

I have put the executable in many different locations (thinking that I was having a problem with symbolic links or something like that). I have also tried giving it the full path to where it is stored. I have had no luck.

I can, however, set $command = "ls" and get a directory list like I would expect. The file permissions on the executable should be 777 at this point to allow any and all access.

Furthermore, I have not been able to get any useful error feedback to the web browser. I would like to see what error message is being display (i.e. No file exists, permission denied, etc.) I get no output from the file, nor is a file created that should be done by the executable. The return code that I receive ($return_val) is an 11, which is not produced by my program.

Any help would be greatly appreciated.
 
The program is one which I have written can compiled and runs fine from the command line.

Runs fine from the command-line as which user? When run through a web server, the command will run using the permissions of the user as which your web server runs. Did you test the program under that user?


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
That was it, it was a file permission problem. Works now. In the future, do you know of a way to get the stderr redirected so that it outputs in the php script. I was getting a seg fault because apache did not have write access on the drive the output file was to be stored to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top