1

I am using shell_exec to run python in php on MacOS

$result = shell_exec('/Users..../python parser.py '.$number.'/'.$newFileName);

php code doesn't wait until python code ends so there is no value in $result and it makes error. how can make php wait until python code ends?

김성원
  • 11
  • 2
  • Actually it should wait. I just tried it with a bash file sleeping 5 sec and echoing something out. Perhaps your py script does not work as expected? EDIT: try your argument with `'`: `"/Users..../python parser.py '{$number}/{$newFileName}'"` – cottton Nov 22 '21 at 03:13
  • The condition that you are mentioning is never possible without explicitly making PHP request asynchronous check out this one https://stackoverflow.com/questions/19735250/running-a-python-script-from-php – Mahmood Hussain Nov 22 '21 at 03:16

0 Answers0