[PHP] system, exec, shell_exec, passthru [RESOLVED]

2006-08-15 Thread p . willis
Hello,

This problem has now been resolved.
The problem as described below was NOT caused by
PHP. The problem was actually a file permissions/ownership problem.

A.) The apache webserver runs as a user with specific
priviledges. On this particular server the webserver runs as user
'apache'.

B.) The file that CGI/PHP 'myprog' was attempting to open for input
was owned by a different user. The user 'apache' had no rights to 
the file.

C.) Because the CGI was unable to open the input file, several
following output files failed to be generated. Thus the error in PHP.

The resolution was to place files, to be accessed by the apache webserver
user, in directories and files that are owned by apache:apache, or 
nobody:nogroup.

chown apache:apache /mydirectory
cd mydirectory
chown apache:apache -R *

[or]

chown nobody:nogroup /mydirectory
cd mydirectory
chown nobody:nogroup -R *

I hope this helps people with similar problems in the future.

All the best,

Peter


Hello,

I am trying the run an external application with
command line arguments using PHP under linux.

ie:

$command=myprog $arg1 $arg2  textfile.txt;
system(echo \$command\  test.txt);
system($command);

$handle=fopen(textfile.txt,r);
if($handle!=NULL)
{
   while(!feof($handle))
   {
   ...
   }
   fclose($handle);
}


I test my input arguments for the 'system' call by dumping
the command into a text file. I can then test the command in 
the console. The commands work fine when run from the console.

The commands don't work when run through the system command.
I have tried system, exec, passthru, and shell_exec to no avail.

Am I missing some permissions thing in my php.ini file?

Thanks for any insight,

Peter


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] system, exec, shell_exec, passthru

2006-08-14 Thread p . willis
Hello,

I am trying the run an external application with
command line arguments using PHP under linux.

ie:

$command=myprog $arg1 $arg2  textfile.txt;
system(echo \$command\  test.txt);
system($command);

$handle=fopen(textfile.txt,r);
if($handle!=NULL)
{
while(!feof($handle))
{
...
}
fclose($handle);
}


I test my input arguments for the 'system' call by dumping
the command into a text file. I can then test the command in 
the console. The commands work fine when run from the console.

The commands don't work when run through the system command.
I have tried system, exec, passthru, and shell_exec to no avail.

Am I missing some permissions thing in my php.ini file?

Thanks for any insight,

Peter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: system, exec, shell_exec, passthru

2006-08-14 Thread p . willis
Yes, that is a similar problem and sounds very much like
what I am experiencing.

Peter


Quoting Michael Jonsson [EMAIL PROTECTED]:
 Hi,
 
 I can run any external program like ls, cp, uptime...
 But if a try to run my shell script a get error.
 
   $passwdexe = sudo /usr/bin/webpasswd;
   $user=$_POST[name];
   $passwd=$passwdexe $user 123456;
   echo $passwd;
   $result = system($passwd);
 
 Resultat from the web, sudo /usr/sbin/webpasswd billy 12345678
 and from the error_log, couldn't read file ./usr/sbin/webpasswd.: no 
 such file or directory.
 
 .Mike

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: system, exec, shell_exec, passthru

2006-08-14 Thread p . willis
Quoting Adam Zey [EMAIL PROTECTED]:

 
 Looking at your $command, there is no path in front of it. It's likely 
 that PHP's shell doesn't have the program in its PATH. Try manually 
 specifying the full path to the command:
 
 $command=/home/peter/myprog $arg1 $arg2  textfile.txt;
 
 (or whatever the path is)
 
 Keep in mind that under linux, (unlike DOS), you CANNOT execute 
 applications in the same directory without a path. Even if the program 
 is in the same directory as your present working directory (which is 
 usually where the PHP script is located), you'd have to do ./myprog as 
 a relative path.
 
 Regards, Adam Zey.

I have actually tried that and it didn't make any difference.
In the actual code I have full paths applied to all input and
output files.

One of the system calls is in the system path. (ie: /usr/bin)


Peter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php