This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Two commands successfully run manually but fail when run in shell_exec(), giving TimeOut error

0

I am trying to execute two dmd commands simultaneously using PHP shell_exec(). One command runs Tshark for 5 seconds. The second command runs an .exe file. Tshark is a program which captures network packs transferring over a network interface. The second program (named mtu.exe) sends network packets from my local machine to a remote machine.

Thing is that when I run these commands manually, I run the first command. A moment after that, I run the second one, and all goes well and within a second or so, the expected packets are transferred by mtu.exe and are captured by tshark.exe. Everything works perfectly well.

But then when I run the following script to execute these commands, I get the following output:

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

Output:

"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

Line 10 is the line where shell_exec() is. The question how to fix this issue? Why is this happening?

asked 29 Apr ‘17, 02:07

Jesss's gravatar image

Jesss
51141720
accept rate: 0%

edited 29 Apr ‘17, 02:08