sumitmehta
New Member
- Messages
- 215
- Reaction score
- 1
- Points
- 0
Sometimes it is necessary to execute exe files from a php script Below is the code used for that.
<?php
$data = array(); // define array
exec('dir', $data, $ret); // execute command, output is array
echo "<pre>";
if ($ret == 0) { // check status code. if successful
foreach ($data as $line) { // process array line by line
echo "$line \n";
}
} else {
echo "Error in command"; // if unsuccessful display error
}
echo "</pre>";
?>
<?php
$data = array(); // define array
exec('dir', $data, $ret); // execute command, output is array
echo "<pre>";
if ($ret == 0) { // check status code. if successful
foreach ($data as $line) { // process array line by line
echo "$line \n";
}
} else {
echo "Error in command"; // if unsuccessful display error
}
echo "</pre>";
?>