Run exe file from php script

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>";
?>
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
sweet...now I can fine tune to to possibly run ffmpeg.exe
 

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
exec() function is blocked, by most of the free web hosts.
 

sunils

New Member
Messages
2,266
Reaction score
0
Points
0
Its a wonderful tutorial.......
But as kajasweb told, the exec() function is disabled in most of the host.
 

sumitmehta

New Member
Messages
215
Reaction score
1
Points
0
I am sorry guys. I didn't know about it. But thanks for telling me and getting me updated.
 

rayxzero

New Member
Messages
7
Reaction score
0
Points
0
Mostly why they blocked exec is because of security. Just like java in order to run applet you need to signed all of your jar files.
 

sumitmehta

New Member
Messages
215
Reaction score
1
Points
0
Ya I understand all those issues. EXE files are always dangerous for servers. It was just a matter of fact that it didn't click my mind that free servers won't be allowing it as my scripts never use exec() functions and so I have never tried it.
 
Top