Jump to content


Photo

exec()


  • Please log in to reply
2 replies to this topic

#1 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 04 August 2006 - 02:53 PM

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

#2 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 04 August 2006 - 03:02 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#3 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 04 August 2006 - 03:52 PM

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

<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>

Try replacing 'pwd' with 'env' to see your PATH. You can also try specifying the full path to php.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users