Click to See Complete Forum and Search --> : EXEC family functions


sandeepshinde
01-17-2007, 05:20 AM
I am trying to use system or exec function to execute a date command, my safe mode is off but still it is giving me the following error

sh: /date: No such file or directory

code used
=============
<?php
echo system('date');

?>

Please let me know the solution if this is a bug

NogDog
01-17-2007, 10:07 AM
Sounds like the webserver user running your PHP scripts does not have a path environment setting pointing to whatever directory the date command is in on your host. You may have to give it the full path, something like:

echo system('/usr/bin/date');

Of course, you could do the above entirely within PHP using the date or strftime functions.

scrupul0us
01-17-2007, 10:30 AM
you could do the above entirely within PHP using the date or strftime functions.

agreed since either will return the time on the webserver

sandeepshinde
01-17-2007, 10:44 AM
Sounds like the webserver user running your PHP scripts does not have a path environment setting pointing to whatever directory the date command is in on your host. You may have to give it the full path, something like:

echo system('/usr/bin/date');

Of course, you could do the above entirely within PHP using the date or strftime functions.


I have tried using this code also but still the issue persist, and i am going :mad:

NogDog
01-17-2007, 12:30 PM
Note that I'm just guessing where the date program would be on your host. It might be something like /usr/sbin/date, /etc/bin/date, and so on.