开发者

Php shell_exec return running process ID

开发者 https://www.devze.com 2023-03-21 11:31 出处:网络
I\'m trying to return a process ID throw a php. In Linux this command return Process ID /receive.sh url=http://www.site.com

I'm trying to return a process ID throw a php. In Linux this command return Process ID

/receive.sh url=http://www.site.com cert=certs/test_lv.p12?test_lv > /dev/null 2>/dev/null &

I need to run this command throw a php.

$response2 = shell_exec("./receive.sh url=https://www.site.com cert=certs/test.p12?test_lv  > /dev/null 2>/dev/null &");
 echo $response2;

It's returned an empty string. Thanks for answers!

Updated* I ad开发者_Go百科ded an ouput PID and it works! Thanks to all!

./receive.sh url=https://www.site.com cert=certs/test_lv.p12?test_lv  > /dev/null 2>/dev/null &  echo $!


I think you code has a bug since it already redirects the output to /dev/null in your command , just try to remove the output redirection and it may work


shell_exec returns the output stream. Your command may print the process id to the error stream and that's why you get an empty string.

Here you can see how to print the error stream. I am not sure if that's your case but give it a try.


Check out popen.

0

精彩评论

暂无评论...
验证码 换一张
取 消