Re: [PHP] Problems with exec() on windows
I can confirm the presence of the same issue on my installation, 5.2.9-2 on Windows XP. Very annoying bug. -- This message was sent on behalf of henrikol...@gmail.com at openSubscriber.com http://www.opensubscriber.com/message/php-general@lists.php.net/11719414.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with exec() on windows
Hi, I'm trying to use exec to call gammu.exe and send sms on windows XP. This works from commandline: C:\path\to\gammu.exe 1 --sendsms EMS 200 -text test1 test2 But if I run it through php like this: $command = \C:\path\to\gammu.exe\ --sendsms EMS 200 -text \test1 test2\.; @exec($command, $response, $retval); This always fails, returns 1 and the response is empty. If the last argument is a string with no spaces, and the double quotes were omitted, it works perfectly. If the double quotes are added around the string with no spaces, it fails again, which makes me believe that the problem is with the double quotes. I've used procmon and it shows that when the double quotes are added around the last argument, gammu.exe is not even called at all. Problem is that the double quotes are required by gammu to send an sms with spaces in it. Any ideas? :-( Luke
Re: [PHP] Problems with exec() on windows
On Thu, Mar 19, 2009 at 9:19 AM, Kyohere Luke pr0...@gmail.com wrote: Hi, I'm trying to use exec to call gammu.exe and send sms on windows XP. This works from commandline: C:\path\to\gammu.exe 1 --sendsms EMS 200 -text test1 test2 But if I run it through php like this: $command = \C:\path\to\gammu.exe\ --sendsms EMS 200 -text \test1 test2\.; @exec($command, $response, $retval); This always fails, returns 1 and the response is empty. If the last argument is a string with no spaces, and the double quotes were omitted, it works perfectly. If the double quotes are added around the string with no spaces, it fails again, which makes me believe that the problem is with the double quotes. I've used procmon and it shows that when the double quotes are added around the last argument, gammu.exe is not even called at all. Problem is that the double quotes are required by gammu to send an sms with spaces in it. I'm not sure if it will help, but the escapeshellarg() function looks like it might handle all that tricky slash-and-quote-adding for you: http://php.net/escapeshellarg Other than that, perhaps proc_open() would do what you need it to by completely separating the command's arguments from itself. http://php.net/proc_open HTH, -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with exec() on windows
On Thu, Mar 19, 2009 at 9:25 AM, haliphax halip...@gmail.com wrote: On Thu, Mar 19, 2009 at 9:19 AM, Kyohere Luke pr0...@gmail.com wrote: Hi, I'm trying to use exec to call gammu.exe and send sms on windows XP. This works from commandline: C:\path\to\gammu.exe 1 --sendsms EMS 200 -text test1 test2 But if I run it through php like this: $command = \C:\path\to\gammu.exe\ --sendsms EMS 200 -text \test1 test2\.; @exec($command, $response, $retval); This always fails, returns 1 and the response is empty. If the last argument is a string with no spaces, and the double quotes were omitted, it works perfectly. If the double quotes are added around the string with no spaces, it fails again, which makes me believe that the problem is with the double quotes. I've used procmon and it shows that when the double quotes are added around the last argument, gammu.exe is not even called at all. Problem is that the double quotes are required by gammu to send an sms with spaces in it. I'm not sure if it will help, but the escapeshellarg() function looks like it might handle all that tricky slash-and-quote-adding for you: http://php.net/escapeshellarg Other than that, perhaps proc_open() would do what you need it to by completely separating the command's arguments from itself. http://php.net/proc_open Also--if you're only concerned with a one-way process tunnel (read or write, but not both) then maybe popen() instead of proc_open() would be preferable for overhead/speed. Of course, that's if either of them do what you're looking for. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with exec() SOLVED
Thanks for the help. :) I posted to the freeBSD list and was given the answer there. in case anyone is interested and for the sake of the archive, I needed a path specified in the shell script. The following URL provides the necessary info for fixing the script. http://linux.dbw.org/shellscript_howto.html again thanks. Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with exec()
What is the safe_mode value in your php.ini? To run exec the value of your safe_mode has to be OFF. [EMAIL PROTECTED] escribió: Try exec('/path/to/copy', $return); print_r($return); read the manual : http://nl3.php.net/manual/en/function.exec.php Description string exec ( string command [, array output [, int return_var]] ) gr, Thijs On Wed, 29 Nov 2006 23:22:13 -0700, Ray [EMAIL PROTECTED] wrote: hello; I am trying to write a script to do some auto configuration of my webserver. Part of the process involves copying some configuration files from other places on the server to a working directory where they can be modified. I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5 I can't seem to get the exec() command to work. I have an external shell script called 'copy' that takes care of getting files. script is currently set to mode 777 when run from the shell it works perfectly. however, in the php script echo exec('whoami'); exec('/path/to/copy'); the only return is 'www' (the username correctly returned from whoami) also files aren't changed. any suggestions, pointers, log files to check would be appreciated as I have spent several hours on google, in manuals, etc. haven't tried the ougi board, but that's about it ;-) tia Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with exec()
Think he's not getting an general error - just didn't read the manual concerning the return value of exec. kind regards jan Juanjo Pascual wrote: What is the safe_mode value in your php.ini? To run exec the value of your safe_mode has to be OFF. [EMAIL PROTECTED] escribió: Try exec('/path/to/copy', $return); print_r($return); read the manual : http://nl3.php.net/manual/en/function.exec.php Description string exec ( string command [, array output [, int return_var]] ) gr, Thijs On Wed, 29 Nov 2006 23:22:13 -0700, Ray [EMAIL PROTECTED] wrote: hello; I am trying to write a script to do some auto configuration of my webserver. Part of the process involves copying some configuration files from other places on the server to a working directory where they can be modified. I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5 I can't seem to get the exec() command to work. I have an external shell script called 'copy' that takes care of getting files. script is currently set to mode 777 when run from the shell it works perfectly. however, in the php script echo exec('whoami'); exec('/path/to/copy'); the only return is 'www' (the username correctly returned from whoami) also files aren't changed. any suggestions, pointers, log files to check would be appreciated as I have spent several hours on google, in manuals, etc. haven't tried the ougi board, but that's about it ;-) tia Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with exec()
Hi, thanks for your help. I was using exec('/path/to/copy', $return); var_dump($return); (but I simplified it for posting) and I was still getting no output. actually, the return value is the least of my concerns, I just want this script to move some files around and the script works from the command line. as for safe_mode, it's off. Also the whoami in the previous line works as expected. Any pointers would be appreciared. Tia Ray -Original Message- From: Jan Schröter [EMAIL PROTECTED] To: php-general@lists.php.net Date: Thu, 30 Nov 2006 09:09:49 +0100 Subject: Re: [PHP] problems with exec() Think he's not getting an general error - just didn't read the manual concerning the return value of exec. kind regards jan Juanjo Pascual wrote: What is the safe_mode value in your php.ini? To run exec the value of your safe_mode has to be OFF. [EMAIL PROTECTED] escribió: Try exec('/path/to/copy', $return); print_r($return); read the manual : http://nl3.php.net/manual/en/function.exec.php Description string exec ( string command [, array output [, int return_var]] ) gr, Thijs On Wed, 29 Nov 2006 23:22:13 -0700, Ray [EMAIL PROTECTED] wrote: hello; I am trying to write a script to do some auto configuration of my webserver. Part of the process involves copying some configuration files from other places on the server to a working directory where they can be modified. I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5 I can't seem to get the exec() command to work. I have an external shell script called 'copy' that takes care of getting files. script is currently set to mode 777 when run from the shell it works perfectly. however, in the php script echo exec('whoami'); exec('/path/to/copy'); the only return is 'www' (the username correctly returned from whoami) also files aren't changed. any suggestions, pointers, log files to check would be appreciated as I have spent several hours on google, in manuals, etc. haven't tried the ougi board, but that's about it ;-) tia Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with exec()
Output you will only get if something goes wrong with the copy process. But then again you say the 'whoami' command runs perfect. So the only things that comes to my sleepy brain is incorrect paths or permissions. Tried it here with 5.2 and 4.4.4 and seems to work. Maybe somebody else has a clue what's going on. On Thu, 30 Nov 2006 07:40:45 -0700, Ray [EMAIL PROTECTED] wrote: Hi, thanks for your help. I was using exec('/path/to/copy', $return); var_dump($return); (but I simplified it for posting) and I was still getting no output. actually, the return value is the least of my concerns, I just want this script to move some files around and the script works from the command line. as for safe_mode, it's off. Also the whoami in the previous line works as expected. Any pointers would be appreciared. Tia Ray -Original Message- From: Jan Schröter [EMAIL PROTECTED] To: php-general@lists.php.net Date: Thu, 30 Nov 2006 09:09:49 +0100 Subject: Re: [PHP] problems with exec() Think he's not getting an general error - just didn't read the manual concerning the return value of exec. kind regards jan Juanjo Pascual wrote: What is the safe_mode value in your php.ini? To run exec the value of your safe_mode has to be OFF. [EMAIL PROTECTED] escribió: Try exec('/path/to/copy', $return); print_r($return); read the manual : http://nl3.php.net/manual/en/function.exec.php Description string exec ( string command [, array output [, int return_var]] ) gr, Thijs On Wed, 29 Nov 2006 23:22:13 -0700, Ray [EMAIL PROTECTED] wrote: hello; I am trying to write a script to do some auto configuration of my webserver. Part of the process involves copying some configuration files from other places on the server to a working directory where they can be modified. I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5 I can't seem to get the exec() command to work. I have an external shell script called 'copy' that takes care of getting files. script is currently set to mode 777 when run from the shell it works perfectly. however, in the php script echo exec('whoami'); exec('/path/to/copy'); the only return is 'www' (the username correctly returned from whoami) also files aren't changed. any suggestions, pointers, log files to check would be appreciated as I have spent several hours on google, in manuals, etc. haven't tried the ougi board, but that's about it ;-) tia Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with exec()
hello; I am trying to write a script to do some auto configuration of my webserver. Part of the process involves copying some configuration files from other places on the server to a working directory where they can be modified. I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5 I can't seem to get the exec() command to work. I have an external shell script called 'copy' that takes care of getting files. script is currently set to mode 777 when run from the shell it works perfectly. however, in the php script echo exec('whoami'); exec('/path/to/copy'); the only return is 'www' (the username correctly returned from whoami) also files aren't changed. any suggestions, pointers, log files to check would be appreciated as I have spent several hours on google, in manuals, etc. haven't tried the ougi board, but that's about it ;-) tia Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with exec()
Try exec('/path/to/copy', $return); print_r($return); read the manual : http://nl3.php.net/manual/en/function.exec.php Description string exec ( string command [, array output [, int return_var]] ) gr, Thijs On Wed, 29 Nov 2006 23:22:13 -0700, Ray [EMAIL PROTECTED] wrote: hello; I am trying to write a script to do some auto configuration of my webserver. Part of the process involves copying some configuration files from other places on the server to a working directory where they can be modified. I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5 I can't seem to get the exec() command to work. I have an external shell script called 'copy' that takes care of getting files. script is currently set to mode 777 when run from the shell it works perfectly. however, in the php script echo exec('whoami'); exec('/path/to/copy'); the only return is 'www' (the username correctly returned from whoami) also files aren't changed. any suggestions, pointers, log files to check would be appreciated as I have spent several hours on google, in manuals, etc. haven't tried the ougi board, but that's about it ;-) tia Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with exec
Hi there I'm having a bit of trouble with executing system commands. My script reads as follows. ? exec(smbclient -L \\xxx.xxx.xxx.xxx -N, $output); print_r($output); ? The problem is that when I run this script the page does not load and apache crashes. Does anyone know a way around this problem?? Thanks
[PHP] problems with 'exec' in 4.3
I'm having problems with the exec command since upgrading to 4.3. Code that previously worked now doesn't. I'm using IIS5 and have checked in the php.ini file to make sure that safe mode is off. Is there anything else that I should check? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with exec and sendfax
Hallo ! i have some problems when trying to use senfax from halyfax within php. i am using php4 on a redhat 6.2 box with the recent version of hylafax and apache. well, i am using the following code: $fd = fopen($tmpPath . $delivery_number, w); set_file_buffer($fd, 0); $size = fwrite($fd, $sFax); $result = fclose($fd); $sFax = /usr/bin/sendfax -n -d 10050732314517 . $tmpPath . $delivery_number . ; exec($sFax, $result, $errno); this returns the $errno 255. I also found the following entry in the http-error-log: /tmp/99472343: Can not determine file type when i call the sendfax command from the shell (even as user nobody) it works fine does anyone know something about this ? thank you ! otto brandstaetter ps: please also let me know your answers under [EMAIL PROTECTED], as i am not subscribed to the mailing list and i do not check the newsgroup regullary. thank you ! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Problems with exec
hi, i have some problems with exec. i am using win2000, apache and latest php version. always 'unable to fork' . what´s the problem? thanks for help, arne -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]