views:

581

answers:

1

My batch file includes following code,

cd C:\Ant
Ant

How can I execute this file in PHP. I've tried everything including, system(); exec(); passthru();

but none of these functions worked for me. Please I need urgent help.

Thanks in advance, -Avirat.

+2  A: 

Batch files are no executables. Try

cmd /c your-batch-file.bat

Here cmd.exe is the executable. The /c options tells cmd to run the following command (here your batch file).

Update:

Without any PHP knowledge: the functions you are trying to use might be disabled due to safe mode.

It would be helpful (for any PHP developers) if you post the code line that tries to call the bat. Maybe you just missed a parameter or something like that.

wierob
No man it's not working, and I am trying to do it in PHP, but whenever I tried it ran in .bat file but when I go through PHP then it doesn't works.
Avirat
Please extend your question with the snippet that tries to call the batch file as well as any error message or hint on the resulting behavior.
wierob
Hi, I would explain you in detail that what i have done and what i want to do.I want to convert the Doc or Pdf or txt files into flashpaper, for this I am using Apache ANT and I was successful in converting those files manually through cmd, but now I want to do it through php, so that whenever a button is clicked the ANT command should run and the file gets converted. Now, please let me know in details which code would you like to view.Thanks, -Avirat.
Avirat
My bat file (ron.bat) contains,cd C:\AntAntand this bat file is executed in my php file temp.php and the code is,system('ron.bat');I also tried using,exec('ron.bat') andpassthru('ron.bat')but when I use system() or passthru(); then it just prints the path in the browser and when I use exec() nothing happens and the page remains blank.
Avirat