Welcome to WebmasterWorld Guest from 54.224.113.125

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

shell exec problem. Any help?

issuing service restart command using shell_exec

     
7:10 am on Jun 9, 2010 (gmt 0)

New User

5+ Year Member

joined:June 6, 2010
posts:4
votes: 0


Hello,
I'm trying to restart bind of my server using php
The commands I generally use with putty are:
service named restart
or
/etc/init.d/named restart
Both work fine.

When I used "any" of those commands with php like:
<?php echo shell_exec("/etc/init.d/named restart"); ?>
I get this output:

Stopping named......[failed]
Starting named named: already running....[failed]

What am I missing here?

I also changed the owner and group of this php script using putty
chown root:root /home/site/rn.php

but it still does the same.

Is it possible to do this using a sh script? If so, please give me the code I need to use in the script. I don't know how to use sh scripts...
Thank you
8:39 pm on June 10, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


is it maybe because the user running php might have permissions issues?
8:12 pm on June 12, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
posts:945
votes: 0


Just a note, the two following are identical functionally

$something = shell_exec("/etc/init.d/named restart");
$something = `/etc/init.d/named restart`;

(Note that I used backticks - not single quotes

Quite a neat little snippet I think :)
[php.net...]