从PHP调用Bash脚本

时间:2017-11-12 02:58:15

标签: php bash

我从PHP调用Bash脚本,但看起来PHP脚本在bash脚本运行完成之前不会完成。

exec(dirname(__FILE__) . '/sendemail.sh');

在bash脚本中,我发送了100多封电子邮件,每次都在睡觉。如果我从命令行启动脚本一切正常。但是当我从Web服务器执行PHP时,php永远不会完成,并且它将永远等待加载页面。

### Get emails one at a time from PHP generated list and start loop. 
cat /home2/xx/www/sendmail/phpmailer/libs/people.txt | while read line 
do
sleep 30
echo "$line" 

### Set path of program that will run.
xmail="/usr/sbin/sendmail"

### Get subject generated from sendpage.php "not sure on name?
xsub=$(cat /home2/xx/www/sm/subject.txt)

### Show from in email.
xfrom="xx@yy.net"

### Get body generated from sendpage.php "not sure on name?
xmsg=$(cat /home2/xx/www/sm/body.txt)

### Compose emails one at a time.
"$xmail" "$line" << EOF
subject:$xsub
from:$xfrom
$xmsg
EOF

### End loop when while is complete.
done

0 个答案:

没有答案