Re: Executing shell command?
| From: | Stut | Date: | Tue, 23 Sep 2008 13:43:22 +0000 |
| Subject: | Re: Executing shell command? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280767@lists.php.net to get a copy of this message | ||
On 23 Sep 2008, at 14:27, Jas wrote:
Ok I am having problems with a command I would like to execute through PHP. I have tried simple backtick operators on the command, passthru, exec, system all with the same results of 0 return code. Here is an example of the command I am attempting to execute if someone could provide me with some insight, examples etc. /usr/bin/dnssec-keygen -a HMAC-MD5 -b 128 -n USER key (which works from a terminal) Here is my php code (I am changing into a writable directory which works fine): chdir( $defined['keys'] ); $cmd = $defined['dnssectool'] . " -a " . $algorithm . " -b " . $key_bit . " -n USER " . $key_name; echo $cmd . "<br>"; system( '$cmd', $ret ); chdir( $defined['virpath'] );Use backticks and add 2>&1 after the command to redirect stderr to stdout. If that still returns check that the user running the PHP script has permission to execute that command. -Stut -- http://stut.net/