我正在尝试使用PHP imgname = strcat('path/',srcFiles(i).name);
img = imread(imgname);
figure, imghandle = imshow(img(:,:,3));
同时执行两个dmd命令。一个命令运行Tshark 5秒钟。第二个命令运行shell_exec()
文件。 Tshark是一个捕获通过网络接口传输的网络包的程序。第二个程序(名为mtu.exe)将网络数据包从本地计算机发送到远程计算机。
当我手动运行这些命令时,我会运行第一个命令。在那之后,我运行第二个,一切顺利,在一秒钟左右,预期的数据包由.exe
传输,并由mtu.exe
捕获。一切都很好。
但是当我运行以下脚本来执行这些命令时,我得到以下输出:
tshark.exe
输出:
$firstCommand = '"C:\Program Files\Wireshark\tshark.exe" -a duration:5 -w capture.pcapng 2>&1';
echo $firstCommand."<br><br>";
$secondCommand = "mtu.exe -d0 -a43020008 -g43010008 -i987654321 -s"Merry Xmass" 2>&1";
echo $secondCommand."<br><br>";
echo shell_exec($firstCommand . " && " . $secondCommand);
第10行是"C:\Program Files\Wireshark\tshark.exe" -a duration:5 -w capture.pcapng 2>&1
mtu.exe -d0 -a43020008 -g43010008 -i987654321 -s"Merry Xmass" 2>&1
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\Test\index.php on line 10
所在的行。如何解决这个问题的问题?为什么会这样?
答案 0 :(得分:1)
使用tshark
在后台运行&
,以便shell在运行mtu
之前不等待它完成。然后使用wait
命令等待后台命令完成。
echo shell_exec($firstCommand . " & " . $secondCommand . "; wait");
这是Unix shell语法,我不知道Windows cmd中是否有任何等价物。