Hi there,
I'm trying to use the PHP exec() or system() (or any other similar function) to run a batch file, but I can't seem to get these to return anything.
The simplest example I've seen is this, which outputs nothing:
<?php
echo system('dir');
?>
The script is running on a windows XP machine on IIS with PHP installed and I've also tried it on my shared hosting account running windows 2003 server/IIS.
Can anyone suggest what I need to do to get this working, or provide any commands I can use for troubleshooting?
Cheers,
Tom
Edit: second example
Based on pavun_cool's answer I tried the following:
<?php
$last_line = system('dir', $retval);
echo 'last_line '.$last_line.'<br/> retval '.$retval;
?>
The output is:
last_line
retval -1
Edit: third example
Based on Manos Dilaverakis I tried the following code
<?php
exec('dir', $response);
foreach($response as $line) {
echo $line . "<br>";
}
?>
The output is:
<br>
I.e. a blank line when displayed in a browser.
Also looking in php.ini
, the following line (which presumably could disable these functions) is empty:
disable_functions =
Does anyone have any further suggestions or anything else I can try?