batch file with php
How to run window batch file in php?
Step 1
Creata bacth file like that
mkdir %1
save the file name as test.bat
step-2
php program
<?
shell_exec("test.bat india");
?>
Run the php automaticaly create one floder
How to run window batch file in php?
Step 1
Creata bacth file like that
mkdir %1
save the file name as test.bat
step-2
php program
<?
shell_exec("test.bat india");
?>
Run the php automaticaly create one floder
Php Php
17 comments:
You write very well.
I've tried executing a bat file using the command shell_exec('webdev.bat') in windows. but its not executing . A blank screen is loaded .
If anyone knows the answer please let me know .
Please start ur code with "php "
short tags might be disabled
If this doesn't works,give full path of .bat file ..
This is my php code
shell_exec('webdev.bat')
both php and bat files in the same folder . If i'm executing the php file . Its not loading anything. But in processing mode for long time.
Please tell me is there any way to execute a bat file using either php or javascript or html
I dd the same thing its working.. I think you just check the permission.. because some times shell_exec ,system commands will have restrictions forced by apache.. based on who is running the application.
By default all the application will run as "nobody".. so "nobody" should have the permission to run this..If possible try to run the code in command prompt.then see the result
Thanks Harish
Its working
now bat file is executed thru php file in command prompt . But i want the same thing to be done in browser . Is it possible?
thanks in advance
Can u tell me ur system details.. php,apache,xampp version..
Now u have to work on apache permission.. then it will because i tried in both its fine.
These are my system details.
wamp 2.0
Apache2.2.11
php5.2.8
Please tell me how to change the apache permission
If you have any system admin's they can help on this.. If u r in linux its easy..
If above doesn't work to u.. give me some time
In linux I tried to run the php file in command prompt but i'm getting
webdev.bat : command not found
my php file
$output = shell_exec("webdev.bat");
echo $output ;
my webdev.bat file
START NOTEPAD.EXE SOME.TXT
how to run the bat file in linux . In windows i'm able to run the bat file in command prompt
sorry .. i just mistaken ...bat can't run in Linux.. it will only run .sh files..
Did you put the file in document root?. and give full permission to that folder(admin)in windows.
Is any wany to open notepad or any other exe using .sh file in linux
thanks
In windows i put my files in document root and the folder is having full permission but still its not running .
I am using xampp and i excuted the file in windows
I copied php(a.php) and bat(a.bat) file to document root
then executed like this
http://localhost/a.php
It opens a note pad..
I am unable to get why its not working for u.. try to install xampp and check if possible
harish thank you very much for answering all of my questions.
can u please tell me how to proceed the same process in linux. u told that we've to use .sh files in linux instead of bat files. how to open the notepad using .sh files and execute that file using php.
Please help me in this.
thanks in advance
Linux will not support .exe files.. Find linux version of note pad if u can(no idea abt that) then execute.
send me the mail harish.kumar15@gmail.com
Post a Comment