Page 1 of 1

system function

Posted: Tue May 08, 2007 11:22 am
by mcog_esteban
Hi.
I have this test code

Code: Select all

<?php

$date = "01/02/2007 12:00:00";
system('date -s'.escapeshellarg($date));

?>
if i run this script using - php -f date.php - , i can set the machine (linux).

if i run this code from a java app (web service), it outputs
Tue Jan 2 12:00:00 WET 2007
to a debug file, but when i check the date on the machine it has not changed.

what i'm missing here?
Thank you.

Posted: Tue May 08, 2007 3:10 pm
by feyd
Likely, the Java app doesn't have the proper permission to perform such action.

Posted: Fri May 11, 2007 6:43 am
by mcog_esteban
feyd wrote:Likely, the Java app doesn't have the proper permission to perform such action.
Ok, i discard the Java from the problem.

This is what i have done.
date.php

Code: Select all

<?php

exec('date -s'.escapeshellarg($argv[1]), $status);
var_dump($status);

?>
date2.php

Code: Select all

<?php

echo shell_exec("php -f date.php 03/03/2007");

?>
if i do
php -f date.php "01/01/2007"
, i can set the system time.
if i do
php -f date2.php
, i can set the system time.
But if i point the browser to date2.php, i get the correct message debug

Code: Select all

Sat Mar 3 00:00:00 WET 2007
, but no changing on the system time.

Any clue of what i'm missing ?
Thank you.

Posted: Fri May 11, 2007 8:29 am
by Grim...
Still permissions.
There's a discussion about it in a thread right above yours: viewtopic.php?t=67518