shell_exec question

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
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

shell_exec question

Post 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
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

It seems reasonable since if you stop Apache all operation and scripts being executed by it stop too.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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?
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post 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.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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?
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

?

you have to do a ".bat" a .lnk is a direct access
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

my mistake!
apache -k stop worked for me only fro mthe command line:(
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

apache -k stop
sorry it works from a batch file but not when i run it from php
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Is it possible to run something like this:

Code: Select all

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