note 85794 added to function.exec
| From: | frantik at osu1 dot php dot net | Date: | Thu, 18 Sep 2008 06:53:18 +0000 |
| Subject: | note 85794 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144501@lists.php.net to get a copy of this message | ||
function _exec($cmd)
{
$WshShell = new COM("WScript.Shell");
$cwd = getcwd();
if (strpos($cwd,' '))
{ if ($pos = strpos($cmd, ' '))
{ $cmd = substr($cmd, 0, $pos) . '" ' . substr($cmd, $pos);
}
else
{ $cmd .= '"';
}
$cwd = '"' . $cwd;
}
$oExec = $WshShell->Run("cmd /C \" $cwd\\$cmd\"", 0,true);
return $oExec == 0 ? true : false;
}
capture output using ob_start() if you like. Extra code looks for spaces and adds quote marks as
they are needed
----
Server IP: 69.147.83.197
Probable Submitter: 71.141.230.246
----
Manual Page -- http://www.php.net/manual/en/function.exec.php
Edit -- https://master.php.net/note/edit/85794
Del: integrated -- https://master.php.net/note/delete/85794/integrated
Del: useless -- https://master.php.net/note/delete/85794/useless
Del: bad code -- https://master.php.net/note/delete/85794/bad+code
Del: spam -- https://master.php.net/note/delete/85794/spam
Del: non-english -- https://master.php.net/note/delete/85794/non-english
Del: in docs -- https://master.php.net/note/delete/85794/in+docs
Del: other reasons-- https://master.php.net/note/delete/85794
Reject -- https://master.php.net/note/reject/85794
Search -- https://master.php.net/manage/user-notes.php