Multiple Command Line Calls with Shell Exec
I have a php site that takes in user fields and creates a json file. I then use a shell_exec call the templater powershell file with the following statement:
shell_exec(‘powershell -File C:\render\templater.ps1 -v “CC 2017” -m’);
However, when more than one person submits the form and a video is rendering the second call doesn’t work?
Do you know why this would be? I have included the -m tag as well.
@wst-shorty Hi There, and thanks for writing into the forums. I think the answer is that you need to run the Powershell launcher as a child or forked process in PHP. I’m not certain how to acheive this in PHP, but there are frameworks for handling child processes in PHP. See the following:
Have you tried using PHP’s exec() instead of shell_exec():
You essentially need to make sure that PHP runs your command as a child process. On Windows, we’ve had success using SysInternals PsExec to run multiple instances of AfterFX.exe from an exec() command. Even though PsExec is intended for launching apps on remote machines, you can still use it to launch an app on the local machine.
Please let me know if this helps in any way, it would be great to learn of your findings.
@ariestav Yeah it seemed to have some weird conflict with PHP and windows running concurrently (its to do with how threading is coded). PsExec helped solve this though. Thanks very much!
@wst-shorty You’re welcome! Thanks for following up and letting us know.