RE: [PHP] I think this is a bug...cant use exec commands.
Thank you all for your collective help. I was very frustrated. This list helped me find the answer quickly and once again PHP is slowly all beginning to make sense. The default values enable safe-mode and that is what Jason was trying to get me to check. Thus when the php.ini wasn't where php thought it was then the engine just used the default values. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I think this is a bug...cant use exec commands.
> They're different, see manual for details. The Manual is brilliant. > exec("free -b", $data ,$result_code); > print_r($data); > > Array > ( > [0] => total used free sharedbuffers > cached > [1] => Mem: 256917504 2494013447516160 0 29487104 > 80941056 > [2] => -/+ buffers/cache: 138973184 117944320 > [3] => Swap:271392768 150523904 120868864 > ) But an example is worth 5000 pages of a manual. That's 2 I owe you Jason. Thank you Sir. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I think this is a bug...cant use exec commands.
On Friday 02 April 2004 23:16, Jay Blanchard wrote: > So there WAS more than one copy of the php.ini! :) No, the php binary (ie not the webserver php module) was *expecting* its php.ini to be located at /var/www/conf. As it wasn't there, the existing copy at /etc/php.ini was copied over. > Have you tried $data = exec("free -b"); ? That will only give the *last* line of output, which I believe, is not what the OP wanted. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* A wise man can see more from the bottom of a well than a fool can from a mountain top. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I think this is a bug...cant use exec commands.
On Friday 02 April 2004 23:09, Brian Duke wrote: > If I wanted to use exec() for this project in the future, is: > > (shell_exec ("free -b")) = (exec("free -b", $data ,$result_code)) They're different, see manual for details. > I tried using exec as > exec("free -b", $data ,$result_code)); > but I didn't get the $data I was expecting. Are my variables mixed up? exec("free -b", $data ,$result_code); print_r($data); Array ( [0] => total used free sharedbuffers cached [1] => Mem: 256917504 2494013447516160 0 29487104 80941056 [2] => -/+ buffers/cache: 138973184 117944320 [3] => Swap:271392768 150523904 120868864 ) Works fine for me. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* In the strict scientific sense we all feed on death -- even vegetarians. -- Spock, "Wolf in the Fold", stardate 3615.4 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I think this is a bug...cant use exec commands.
[snip] I tried the php -I found php was looking for the php.ini in /var/www/conf. I copied php.ini from /etc/ to /var/www/conf. Now the shell_exec works fine. (shell_exec ("free -b")) = (exec("free -b", $data ,$result_code)) I tried using exec as exec("free -b", $data ,$result_code)); but I didn't get the $data I was expecting. Are my variables mixed up? [/snip] So there WAS more than one copy of the php.ini! :) Have you tried $data = exec("free -b"); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I think this is a bug...cant use exec commands.
Forgive the top-post. I tried the php -I found php was looking for the php.ini in /var/www/conf. I copied php.ini from /etc/ to /var/www/conf. Now the shell_exec works fine. Thanks Jason. If I wanted to use exec() for this project in the future, is: (shell_exec ("free -b")) = (exec("free -b", $data ,$result_code)) I tried using exec as exec("free -b", $data ,$result_code)); but I didn't get the $data I was expecting. Are my variables mixed up? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I think this is a bug...cant use exec commands.
Yes, in fact to be sure I copied free into my /var/www/html/swap directory and used that path. It still says. [EMAIL PROTECTED] swap]# php swap.php sh: line 1: /usr/local/php/bin/free: No such file or directory even though I explicitly said exec ("/var/www/html/swap/free -b", $data, $result); -Original Message- From: Daevid Vincent [mailto:[EMAIL PROTECTED] Sent: Friday, April 02, 2004 12:51 AM To: 'Brian Duke'; 'Jay Blanchard'; 'William Lovaton'; [EMAIL PROTECTED] Subject: RE: [PHP] I think this is a bug...cant use exec commands. This may seem obvious, but did you try the FULL path to 'free'? As in exec("/usr/local/bin/free -b", $data, $result); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I think this is a bug...cant use exec commands.
On Friday 02 April 2004 15:20, Brian Duke wrote: Please do not top post! > Ok here is my php.ini. directly from /etc/php.ini OK, is this where *you* think php.ini should be located? Or did you follow these instructions: > > executable? If the former use phpinfo() to find out where php thinks it's > > php.ini should be found, if the latter use "php -i". Once you've > > determined where your php.ini should be examine its safe_mode settings. to find out where *php* thinks php.ini should be located? > [EMAIL PROTECTED] swap]# php mem.php > sh: line 1: /usr/local/php/bin/free: No such file or directory Don't you get the safe_mode warning/error message anymore? As for the above error, try using exec("/full/path/to/free -b", ...). > The php-4.3.5 in not installed yet. I just downloaded it and untarred the > contents in my download directory. We run the program via the web it's for > MRTG graphs. I was using an example I found on the web. Here is the result > when I change line 1 using exec() I hope you know what you're doing if you're trying to install php from source over an existing RPM installation! -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* We don't smoke and we don't chew, and we don't go with girls that do. -- Walter Summers */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I think this is a bug...cant use exec commands.
This may seem obvious, but did you try the FULL path to 'free'? As in exec("/usr/local/bin/free -b", $data, $result); > -Original Message- > From: Brian Duke [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 01, 2004 9:57 PM > To: 'Jay Blanchard'; 'William Lovaton'; [EMAIL PROTECTED] > Subject: RE: [PHP] I think this is a bug...cant use exec commands. > > I tell you the truth. I have only 1 php.ini. There are other > ini files I > have looked at but I have not found anything in them about safe mode. > Everything has been double or triple checked. Still not able run any > shell_exec commands from the command line. > > I need the output from free so if I use exec() > > exec("free -b", $data, $result); > $data = str_replace(' ',' ',$data); > $data = str_replace(' ',' ',$data); > $data = str_replace(' ',' ',$data); > $data = str_replace(' ',' ',$data); > $dataArray = explode(' ',$data); > $total = $dataArray[16]; > $used = $dataArray[17]; > echo $used.chr(10); > echo $total.chr(10); > ?> > > Exec complains that "free" is not in /usr/local/php/bin/ > directory. ( I > think that's the directory but whatever it was, it wasn't > pointing at the > web directory where my script is.) Really someone should try > this script. > It's harmless. 'Free' is a nix command. > > And BTW > > [snip from original] > > Warning: shell_exec(): Cannot execute using backquotes in > Safe Mode in > > /var/www/html/swap/mem.php on line 3 > [/snip] > > Is how that line should read. The complaint is about the script I an\m > running called mem.php. Originally named swap.php. I wasn't > paying close > enough attention when I cut from the bugs.php.net page and pasted. :) > > -- > 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] I think this is a bug...cant use exec commands.
Oops I catted the wrong file. But the file is exactly the same as mem.php. [EMAIL PROTECTED] swap]# cat mem.php -Original Message- From: Brian Duke [mailto:[EMAIL PROTECTED] Sent: Friday, April 02, 2004 12:21 AM To: 'Jason Wong'; [EMAIL PROTECTED] Subject: RE: [PHP] I think this is a bug...cant use exec commands. Ok here is my php.ini. directly from /etc/php.ini ; Safe Mode ; safe_mode = Off ; By default, Safe Mode does a UID compare check when ; opening files. If you want to relax this to a GID compare, ; then turn on safe_mode_gid. safe_mode_gid = Off ; When safe_mode is on, UID/GID checks are bypassed when ; including files from this directory and its subdirectories. ; (directory must also be in include_path or full path must ; be used when including) safe_mode_include_dir = ; When safe_mode is on, only executables located in the safe_mode_exec_dir ; will be allowed to be executed via the exec family of functions. safe_mode_exec_dir = /var/www/html/swap/ I am on a redhat 9.0 machine so I use the locate command after a fresh updatedb andf this is all the ini files I was talking about. [EMAIL PROTECTED] swap]# updatedb [EMAIL PROTECTED] swap]# locate php.ini /etc/php.ini /etc/php.ini.rpmsave /root/php-4.3.4/php.ini-recommended /root/php.ini.rpmsave /home/bduke/downloads/php/php-4.3.5/pear/tests/php.ini.tst /home/bduke/downloads/php/php-4.3.5/php.ini-recommended /home/bduke/downloads/php/php-4.3.5/php.ini-dist The php-4.3.5 in not installed yet. I just downloaded it and untarred the contents in my download directory. We run the program via the web it's for MRTG graphs. I was using an example I found on the web. Here is the result when I change line 1 using exec() [EMAIL PROTECTED] swap]# cat swap.php [EMAIL PROTECTED] swap]# php mem.php sh: line 1: /usr/local/php/bin/free: No such file or directory [EMAIL PROTECTED] swap]# pwd /var/www/html/swap [EMAIL PROTECTED] swap]# ls ./free ./free [EMAIL PROTECTED] swap]# The MRTG will call the program via a cgi script. It calls this program only when the data is requested that way we save on cycle time. -Original Message- From: Jason Wong What are these other ini files you've looked at? How are you executing this script? Via a webserver or directly using the php executable? If the former use phpinfo() to find out where php thinks it's php.ini should be found, if the latter use "php -i". Once you've determined where your php.ini should be examine its safe_mode settings. -- 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] I think this is a bug...cant use exec commands.
Ok here is my php.ini. directly from /etc/php.ini ; Safe Mode ; safe_mode = Off ; By default, Safe Mode does a UID compare check when ; opening files. If you want to relax this to a GID compare, ; then turn on safe_mode_gid. safe_mode_gid = Off ; When safe_mode is on, UID/GID checks are bypassed when ; including files from this directory and its subdirectories. ; (directory must also be in include_path or full path must ; be used when including) safe_mode_include_dir = ; When safe_mode is on, only executables located in the safe_mode_exec_dir ; will be allowed to be executed via the exec family of functions. safe_mode_exec_dir = /var/www/html/swap/ I am on a redhat 9.0 machine so I use the locate command after a fresh updatedb andf this is all the ini files I was talking about. [EMAIL PROTECTED] swap]# updatedb [EMAIL PROTECTED] swap]# locate php.ini /etc/php.ini /etc/php.ini.rpmsave /root/php-4.3.4/php.ini-recommended /root/php.ini.rpmsave /home/bduke/downloads/php/php-4.3.5/pear/tests/php.ini.tst /home/bduke/downloads/php/php-4.3.5/php.ini-recommended /home/bduke/downloads/php/php-4.3.5/php.ini-dist The php-4.3.5 in not installed yet. I just downloaded it and untarred the contents in my download directory. We run the program via the web it's for MRTG graphs. I was using an example I found on the web. Here is the result when I change line 1 using exec() [EMAIL PROTECTED] swap]# cat swap.php [EMAIL PROTECTED] swap]# php mem.php sh: line 1: /usr/local/php/bin/free: No such file or directory [EMAIL PROTECTED] swap]# pwd /var/www/html/swap [EMAIL PROTECTED] swap]# ls ./free ./free [EMAIL PROTECTED] swap]# The MRTG will call the program via a cgi script. It calls this program only when the data is requested that way we save on cycle time. -Original Message- From: Jason Wong What are these other ini files you've looked at? How are you executing this script? Via a webserver or directly using the php executable? If the former use phpinfo() to find out where php thinks it's php.ini should be found, if the latter use "php -i". Once you've determined where your php.ini should be examine its safe_mode settings. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I think this is a bug...cant use exec commands.
On Friday 02 April 2004 13:57, Brian Duke wrote: > I tell you the truth. I have only 1 php.ini. There are other ini files I > have looked at but I have not found anything in them about safe mode. What are these other ini files you've looked at? > Everything has been double or triple checked. Still not able run any > shell_exec commands from the command line. How are you executing this script? Via a webserver or directly using the php executable? If the former use phpinfo() to find out where php thinks it's php.ini should be found, if the latter use "php -i". Once you've determined where your php.ini should be examine its safe_mode settings. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* There is always one thing to remember: writers are always selling somebody out. -- Joan Didion, "Slouching Towards Bethlehem" */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I think this is a bug...cant use exec commands.
I tell you the truth. I have only 1 php.ini. There are other ini files I have looked at but I have not found anything in them about safe mode. Everything has been double or triple checked. Still not able run any shell_exec commands from the command line. I need the output from free so if I use exec() Exec complains that "free" is not in /usr/local/php/bin/ directory. ( I think that's the directory but whatever it was, it wasn't pointing at the web directory where my script is.) Really someone should try this script. It's harmless. 'Free' is a nix command. And BTW [snip from original] > Warning: shell_exec(): Cannot execute using backquotes in Safe Mode in > /var/www/html/swap/mem.php on line 3 [/snip] Is how that line should read. The complaint is about the script I an\m running called mem.php. Originally named swap.php. I wasn't paying close enough attention when I cut from the bugs.php.net page and pasted. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I think this is a bug...cant use exec commands.
[snip] May be you can look at exec() function: http://www.php.net/manual/en/function.exec.php [/snip] >From that page... Note: When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir. For practical reasons it is currently not allowed to have .. components in the path to the executable. Warning With safe mode enabled, all words following the initial command string are treated as a single argument. Thus, echo y | echo x becomes echo "y | echo x". [snip from original] > Warning: shell_exec(): Cannot execute using backquotes in Safe Mode in > /var/www/html/swap/swap.php on line 3 [/snip] He goes on to say that safe mode is not enabled on his machine in his php.ini, but perhaps he has more than one and is looking at the wrong one. What is thelocation of the php.ini when you run phpinfo()? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I think this is a bug...cant use exec commands.
May be you can look at exec() function: http://www.php.net/manual/en/function.exec.php I know this doesn't solve the problem but gives you an option to workaround the problem. The curious thing about the warning message is: where are the backquotes in your code?? -William El jue, 01-04-2004 a las 01:54, Brian Duke escribió: > I can't seem to use the shell_exec() command. > > Here is the program: > > > > > > > $data = shell_exec("free -b"); > > $data = str_replace(' ',' ',$data); > > $data = str_replace(' ',' ',$data); > > $data = str_replace(' ',' ',$data); > > $data = str_replace(' ',' ',$data); > > $dataArray = explode(' ',$data); > > > > $total = $dataArray[16]; > > $used = $dataArray[17]; > > > > echo $used.chr(10); > > echo $total.chr(10); > > ?> > > > > I can make this script executable via chmod 700 mem.php and run it directly > via the command line. Only then I can get it to work on my redhat 9 machine. > > The problem is I call this script from another script to plot out the data > on MRTG graphs. > > > > I expect to see something like : > > > > [EMAIL PROTECTED] php-4.3.2]# php /var/www/html/swap/mem.php > > > > 246789242 > > 512689734 > > > > [EMAIL PROTECTED] php-4.3.2]# > > > > But in fact I get the warning : > > > [EMAIL PROTECTED] php-4.3.2]# php /var/www/html/swap/mem.php > > Warning: shell_exec(): Cannot execute using backquotes in Safe Mode in > /var/www/html/swap/swap.php on line 3 > > [EMAIL PROTECTED] php-4.3.2]# > > The warning would be applicable if any php.ini file on my system had Safe > Mode enabled. As the bug people said shell_exec() == ``. But that applies > if anywhere on my box safemode was enabled. I have spent 4 solid days > looking and verifying there is no safe mode enabled on my box. It's an > internal monitoring server there is absolutely no need for safe mode. This > is what is in my PHP.ini > > > > ; Safe Mode > > ; > > safe_mode = Off > > safe_mode_gid = Off > > > > Can someone tell me if they can run that script on their *nix machine? I'm > running php 4.32 apache 2.0 server on a up-to-date redhat 9 server. I don't > think this script can be run from another program. > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I think this is a bug...cant use exec commands.
I can't seem to use the shell_exec() command. Here is the program: I can make this script executable via chmod 700 mem.php and run it directly via the command line. Only then I can get it to work on my redhat 9 machine. The problem is I call this script from another script to plot out the data on MRTG graphs. I expect to see something like : [EMAIL PROTECTED] php-4.3.2]# php /var/www/html/swap/mem.php 246789242 512689734 [EMAIL PROTECTED] php-4.3.2]# But in fact I get the warning : [EMAIL PROTECTED] php-4.3.2]# php /var/www/html/swap/mem.php Warning: shell_exec(): Cannot execute using backquotes in Safe Mode in /var/www/html/swap/swap.php on line 3 [EMAIL PROTECTED] php-4.3.2]# The warning would be applicable if any php.ini file on my system had Safe Mode enabled. As the bug people said shell_exec() == ``. But that applies if anywhere on my box safemode was enabled. I have spent 4 solid days looking and verifying there is no safe mode enabled on my box. It's an internal monitoring server there is absolutely no need for safe mode. This is what is in my PHP.ini ; Safe Mode ; safe_mode = Off safe_mode_gid = Off Can someone tell me if they can run that script on their *nix machine? I'm running php 4.32 apache 2.0 server on a up-to-date redhat 9 server. I don't think this script can be run from another program.