开发者

Php shell_exec return running process ID

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜