Page 1 of 1

shell_exec question

Posted: Tue Mar 09, 2004 7:57 am
by pelegk2
i am running a shell_exec command whih runs this bacth file :

Code: Select all

net stop apache2
net start apache2
the problem is that when i run it the stop command is executed but not the start command!
it seem's like the stop command kills the batch file that is working too!
what can i do?
thanks in advance

Posted: Tue Mar 09, 2004 8:12 am
by scorphus
It seems reasonable since if you stop Apache all operation and scripts being executed by it stop too.

Posted: Tue Mar 09, 2004 10:08 am
by infolock
if ur using windows, try looking into scheduled tasks manager. dunno if you are running this script at a certain time, but you could the scheduler to restart apache at a certain time, which would be a small workaround on this.

Posted: Wed Mar 10, 2004 5:32 am
by pelegk2
the problem is that i can't use scheduled tasks beacuse i dont =know in advance when i need to restart!
what else can i do
?
is there a way to schedule task th will happen in 2 seconds from now?

Posted: Wed Mar 10, 2004 5:34 am
by AVATAr
why dont you do a bat (in windows) or a shell script (in linux) that do that, en from php you simply execute it.

Like scorphus said, if you stop apache... good bye.

Posted: Wed Mar 10, 2004 5:44 am
by pelegk2
i did a bacth file that do :

"C:\Program Files\Apache Group\Apache2\bin\Apache.exe" -k restart

but it dosnet work when i call it from apache like this :
shell_exec("Apach.lnk");

what else can i do?

Posted: Wed Mar 10, 2004 5:48 am
by AVATAr
?

you have to do a ".bat" a .lnk is a direct access

Posted: Wed Mar 10, 2004 5:58 am
by pelegk2
AVATAr i did both of the!!!!
when i run it from command line or doule click on the link everything works ok
but when i run it from php using the shell_exec it isnt wokring!
it only worked on th batch file with the stop command :
apache -k stop
when i tried
apache -k restart it isnt wokring what else can i do>?
thanks in advance
peleg

Posted: Wed Mar 10, 2004 6:12 am
by pelegk2
my mistake!
apache -k stop worked for me only fro mthe command line:(

Posted: Wed Mar 10, 2004 6:16 am
by pelegk2
apache -k stop
sorry it works from a batch file but not when i run it from php

Posted: Wed Mar 10, 2004 4:27 pm
by scorphus
Is it possible to run something like this:

Code: Select all

net restart apache2
Then the 'net' daemon loads Apache2 for you.