note 69789 added to ref.exec
| From: | t dot kramer at NOSPAM dot safetbus dot de | Date: | Thu, 21 Sep 2006 09:21:08 +0000 |
| Subject: | note 69789 added to ref.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117371@lists.php.net to get a copy of this message | ||
Trying to us the following code failed badly with various results: like "unable to fork",
"access denied", "empty results", depending on what settings I used, ... even
though the same code worked from command line on the server itself.
$retstr = exec('nslookup -type=mx myhost.com', $retarr);
Instead of nslookup I believe this would apply to most programs from the \system32\ directory.
I had to learn that the following finally worked:
$retstr = exec('c:\php\safedir\nslookup -type=mx myhost.com', $retarr);
... but only under the listed preconditions:
1: nslookup.exe is placed (copied) in the directory \php\safedir\
2: the directory \php\safedir\ is included in the system PATH environement variable
3: the file cmd.exe is placed in \php\ as listed by other notes above
4: the directory "c:\php\safedir\" is set in the php.ini setting
safe_mode_exec_dir = "c:\php\safedir\"
.. maybe set in php-activescript.ini as well, depending on your system setup.
5: nslookup is referenced by the full path as otherwise the file from \windows\system32\ will be
called. This happend to me with empty result due to missing rights!
Hope this helps somebody saving some time and headaches.
Thomas
----
Server IP: 212.124.37.9
Probable Submitter: 217.110.67.35 (proxied: 1.1 SRV-PROXY)
----
Manual Page -- http://www.php.net/manual/en/ref.exec.php
Edit -- https://master.php.net/note/edit/69789
Del: integrated -- https://master.php.net/note/delete/69789/integrated
Del: useless -- https://master.php.net/note/delete/69789/useless
Del: bad code -- https://master.php.net/note/delete/69789/bad+code
Del: spam -- https://master.php.net/note/delete/69789/spam
Del: non-english -- https://master.php.net/note/delete/69789/non-english
Del: in docs -- https://master.php.net/note/delete/69789/in+docs
Del: other reasons-- https://master.php.net/note/delete/69789
Reject -- https://master.php.net/note/reject/69789
Search -- https://master.php.net/manage/user-notes.php