I got a problem. My PHP script abort if i run an mysql command:
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.
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.
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". But if u do a connection wit ssh2_exec() all alias are unknown.
All i have to do is this.
ssh2_exec($session, 'mysql -u user -ppassword -sse "SELECT COUNT(*) FROM table"');
Thank U!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.