Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

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

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?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Run tshark in the background with & so the shell doesn't wait for it to finish before running mtu. Then use the wait command to wait for the background command to finish.

echo shell_exec($firstCommand . " & " . $secondCommand . "; wait");

This is Unix shell syntax, I don't know if there's anything equivalent in Windows cmd.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda