[英]how to run a bash script from php?
i am trying to sun a bash script when i update something: 我在更新某些内容时尝试使用bash脚本:
public function reloadServer()
{
exec ('/var/www/html/script', $y);
Zend_Debug::dump($y);
}
this is the script
file 这是
script
文件
#!/bin/bash
# test
ssh root@192.168.526.33 "server -rx reload"
echo "success"
what happens is that get the success
message, but the command doesn't get run. 发生的情况是获取
success
消息,但命令未运行。 if i run the command manually it works just fine 如果我手动运行命令,它会很好
note: i can't use ssh2_exec
because of some problems on my server 注意:由于服务器上的某些问题,我无法使用
ssh2_exec
any ideas on what is happening or how can i debug that bash script ? 关于正在发生的事情或如何调试该bash脚本的任何想法?
Place your command inside a subshell and tee its output: 将您的命令放在一个子外壳中,并准备其输出:
#!/bin/bash
# test
( ssh root@192.168.526.33 "server -rx reload" ) 2>&1 | tee -a /some/where.log
echo "success"
Through that you'll see all the messages including possible messages from bash. 通过该操作,您将看到所有消息,包括来自bash的可能消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.