В Linux вы можете использовать shell_exec
функцию:
http://php.net/manual/ro/function.shell-exec.php
В Windows вы можете использовать:
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;
}
Или даже использовать что-то для хранения вашегожурналы как это:
<?php
define ('EXEC_TMP_DIR', 'C:\tmp');
function windExec($cmd,$mode=''){
// runs a command line and returns
// the output even for Wind XP SP2
// example: $cmd = "fullpath.exe -arg1 -arg2"
// $outputString = windExec($cmd, "FG");
// OR windExec($cmd);
// (no output since it runs in BG by default)
// for output requires that EXEC_TMP_DIR be defined
// Setup the command to run from "run"
$cmdline = "cmd /C $cmd";
// set-up the output and mode
if ($mode=='FG'){
$outputfile = EXEC_TMP_DIR . "\\" . time() . ".txt";
$cmdline .= " > $outputfile";
$m = true;
}
else $m = false;
// Make a new instance of the COM object
$WshShell = new COM("WScript.Shell");
// Make the command window but dont show it.
$oExec = $WshShell->Run($cmdline, 0, $m);
if ($outputfile){
// Read the tmp file.
$retStr = file_get_contents($outputfile);
// Delete the temp_file.
unlink($outputfile);
}
else $retStr = "";
return $retStr;
}