Home > Backend Development > PHP Tutorial > PHP's exec function executes the bat script

PHP's exec function executes the bat script

WBOY
Release: 2016-10-17 09:30:22
Original
3304 people have browsed it

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);

Reply content:

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template