Jump to content

exec()


AV1611

Recommended Posts

OK

I have linux (seems relevant LOL)

if I do this from the command line:

root# php myfile.php

it executes this fine:

myfile.php

<?php
exec(xmame romfile);
?>

and xmame launches fine.

BUT
if I run the same from the browser, it doesn't give an error, but doesn't run.

QUESTION:

Is is possible to launch a executable from the browser? or must I learn another language? (perl?)

(My goal is to write a front end for xmame that uses the web browser, php and mysql)

It would have to be run locally obviously

thanks
Link to comment
https://forums.phpfreaks.com/topic/16549-exec/
Share on other sites

I don't understand when someone says command line, all I deal with is host based php/mysql programming, I never ran it from a straight server, as for exec, it should work, if not I think system()
there about the same, the main thing is though don't feed user input into system it's dangerous.
Link to comment
https://forums.phpfreaks.com/topic/16549-exec/#findComment-69208
Share on other sites

php probably isn't in apache's path. Something simple like pwd should work:

[code]
<pre>
<?php
exec('pwd', $output, $return);
echo "Returned: $return<br /><br />";
if ($return) {
echo 'There was a problem.';
}
else {
echo "Output:<br />";
print_r($output);
}
?>
</pre>
[/code]

Try replacing 'pwd' with 'env' to see your PATH. You can also try specifying the full path to php.
Link to comment
https://forums.phpfreaks.com/topic/16549-exec/#findComment-69252
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.