Home >Backend Development >PHP Tutorial >PHP's exec function executes the bat script
The exec function in PHP executes the bat script. Why does it sometimes work but sometimes fail? ?
bat script
@echo off
^
ffmpeg -f concat -i C:^AMP^apache2.4^htdocs^test^upload^2016-10-12^wu_1aurf2i6412121lrl4id1rqr1vgj0^filelist.txt -c copy C:^AMP^ apache2.4^htdocs^test^upload^2016-10-12^57fdaea7c33d7.mpg
^
cd /
^
rd /S /Q C:^AMP^apache2.4^htdocs^test^upload^2016-10- 12^wu_1aurf2i6412121lrl4id1rqr1vgj0
^
echo finished
^
php execution code:
$cmd="C:AMPapache2.4htdocstestupload2016-10-12wu_1aurf2i6412121lrl4id1rq r1vgj0merg.bat";
//$cmd = "./.. /merg.bat";
$res = exec($cmd);
var_dump($res);
The exec function in PHP executes the bat script. Why does it sometimes work but sometimes fail? ?
bat script
@echo off
^
ffmpeg -f concat -i C:^AMP^apache2.4^htdocs^test^upload^2016-10-12^wu_1aurf2i6412121lrl4id1rqr1vgj0^filelist.txt -c copy C:^AMP^ apache2.4^htdocs^test^upload^2016-10-12^57fdaea7c33d7.mpg
^
cd /
^
rd /S /Q C:^AMP^apache2.4^htdocs^test^upload^2016-10- 12^wu_1aurf2i6412121lrl4id1rqr1vgj0
^
echo finished
^
php execution code:
$cmd="C:AMPapache2.4htdocstestupload2016-10-12wu_1aurf2i6412121lrl4id1rq r1vgj0merg.bat";
//$cmd = "./.. /merg.bat";
$res = exec($cmd);
var_dump($res);
Check the ffmpeg log to locate
You can use status to judge and repeat the execution to ensure the results.
Thanks for the invitation. Whether the bat
files are executed concurrently and the same file is operated at the same time, causing an error. The method mentioned above is also a method of troubleshooting.