system function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mcog_esteban
Forum Contributor
Posts: 127
Joined: Tue Dec 30, 2003 3:28 pm

system function

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Likely, the Java app doesn't have the proper permission to perform such action.
mcog_esteban
Forum Contributor
Posts: 127
Joined: Tue Dec 30, 2003 3:28 pm

Post 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.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Still permissions.
There's a discussion about it in a thread right above yours: viewtopic.php?t=67518
Post Reply