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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.