[英]I get no results from ssh2_exec() with a mysql command
I got a problem. 我有问题 My PHP script abort if i run an mysql command: 如果我运行mysql命令,我的PHP脚本将中止:
ssh2_exec($session, 'mysql -sse "SELECT COUNT(*) FROM table"');
With putty is the command no problem. 用腻子是没问题的命令。 Any other commands like 'll -la' or what else are no problem. 其他任何命令,例如'll -la'或其他都没有问题。
Can u tell me why it isn't working? 您能告诉我为什么它不起作用吗?
Bye mok 再见
I don't know the -sse
option, but I guess your problem is that ssh2_exec
returns a stream and not a string. 我不知道-sse
选项,但是我想您的问题是ssh2_exec
返回流而不是字符串。
You can try using: 您可以尝试使用:
$stream = ssh2_exec($session, 'echo "SELECT COUNT(*) FROM table" | mysql');
$output = stream_get_contents($stream);
Okay... i got it now. 好吧...我现在知道了。
The command "mysql" is in my system an alias to "mysql -u user -ppassword". 在我的系统中,命令“ mysql”是“ mysql -u user -ppassword”的别名。 But if u do a connection wit ssh2_exec() all alias are unknown. 但是,如果您使用ssh2_exec()建立连接,则所有别名都是未知的。
All i have to do is this. 我要做的就是这个。
ssh2_exec($session, 'mysql -u user -ppassword -sse "SELECT COUNT(*) FROM table"');
Thank U! 感谢你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.