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

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

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.