note 25068 added to function.exec
| From: | iceburn at dangerzone dot c | Date: | Mon, 09 Sep 2002 22:20:25 +0000 |
| Subject: | note 25068 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36409@lists.php.net to get a copy of this message | ||
This seems to work for me on win2k server w/ iis 5 w/ php 4.2.2....
<?php
if(getenv("OS")!="Windows_NT")
{
echo "This script runs only under Windows NT";
}
$tmp = exec("usrstat.exe Domain", $results);
foreach ($ping_results as $row) echo $row . "<br>";
echo "done";
?>
For those that don't know what usrstat is, it's a program that is the admin pack for win2k
that lists users in a domain and thier last logon time. I used it as the example to show that
arguments can be passed (the domain).
The one "gotcha" is that usrstat.exe must be in the system path...ie if you are at the
server w/ a command window, anything you can type w/o typing in a path, works. Try it with ping,
since that should be in system32 for just about everyone...
I've tried things like:
exec("c:\temp\usrstatexe...
exec("cmd /c c:\temp\usrstat.exe...
but can't seem to get anywhere with those...
even putting the exe on a shared drive with identical paths for the client and server to the exe
doesn't work (don't know why that would fix it, but was just trying things...)
--
http://www.php.net/manual/en/function.exec.php
http://master.php.net/manage/user-notes.php?action=edit+25068
http://master.php.net/manage/user-notes.php?action=delete+25068
http://master.php.net/manage/user-notes.php?action=reject+25068