954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

execute program from command line using php

I uploaded a windows program (.exe) to my windows server. I now need to execute it and pass through a parameter using PHP.. how would i do this? On my computer i would just do this throught the command line, so i not sure how to go about this with PHP.. sorry if this doesnt make a whole lot of sense.. NOOB here..

here is the command i would enter on my machine to run it through the command line.

SCOT.exe -f "C:/GSdata/Scotbatchfile.tsv"

and ideas?


thanks

danimal132
Newbie Poster
18 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

You will need to compile or allow the option to execute on the server with in php.

Check to see if php allow the exec command.

<?php
function exec_enabled() {
  $disabled = explode(', ', ini_get('disable_functions'));
  return !in_array('exec', $disabled);
}
?>


You will need to add executable permissions to the file.

You can then:

<?php
exec("C:\\PATH\\TO\\FILE.exe")
?>


Hope that helps, its not really a very safe thing to have enabled, do not allow users to pass directly to this command.

For more info check the php man pages. http://php.net/manual/en/function.exec.php

omol
Junior Poster
156 posts since Jul 2004
Reputation Points: 10
Solved Threads: 10
 

so will that function above enable php to execute on the server? sorry about this.. so will all i need to do is run that function to allow the php to execute the fuction?

danimal132
Newbie Poster
18 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: