Page 1 of 1
php and .bat
Posted: Sun Apr 29, 2007 3:14 pm
by benyboi
is there a way for me, in a .php page when loaded, to make it run a .bat file on the server? hope you understand...
thanks for your help!
Posted: Sun Apr 29, 2007 3:21 pm
by kbrown3074
There is a way you can do it, just dont know the exact syntax. Something like system <i>filename.bat</i>
Posted: Sun Apr 29, 2007 3:33 pm
by John Cartwright
Posted: Sun Apr 29, 2007 3:59 pm
by benyboi
ok, thanks
would i be able to put a path to a .bat file in the $command vairable? I tried but it just gives a blank page?
thanks
Posted: Sun Apr 29, 2007 4:06 pm
by Ollie Saunders
The backtick operator is a nicer way of saying system()
Code: Select all
$var = 'foo'; echo `C:\whatever\someFile.bat cmd line args $var`;
Be very careful with variables in the command line because if the user can control them in anyway i.e. via $_GET, $_POST or indirectly via a database then they might be able to run nasty commands.
Posted: Mon Apr 30, 2007 5:01 pm
by RobertGonzalez
benyboi wrote:I tried but it just gives a blank page?
Blank pages almost suggest a parse error of some sort.
Posted: Wed May 02, 2007 12:44 am
by neel_basu
Use error_reporting(E_ALL); at the top of your page
and did you tried using exec('your_file.bat');