I'm trying to connect to a mysql database through an SSH connection using NET_SSH. I'm using the interactive shell with read and write.
My code looks like this:
echo '<pre>';
$ssh -> setTimeout(10);
echo $ssh -> read('');
$ssh -> write('ls');
echo $ssh -> read('');
echo '<br />';
$string = 'mysql -u '. $database -> database_user . ' -h ' . $database -> datbase_host . ' --password=' . $database -> database_password . ' ' . $database -> database_name. '; show databases;';
$ssh -> write($string);
echo $ssh -> read('mysql>');
echo '<br />';
$this -> write('show databases;');
echo $ssh -> read('');
echo '<br />';
But my output looks like this:
lsubuntu@ip-xxxxxx:~$ ls
Last login: Fri Dec 28 16:08:39 2012 from ool3.dyn.optonline.net
mysql -u db_user -h xxx.us-east-1.rds.amazonaws.com --password=abc123 my_database; show databases;ubuntu@ip-xxxxxx:~$ mysql -u db_user -h xxx.rds.amazonaws.com --password=abc123 my_database; show databases;
Last login: Fri Dec 28 16:08:49 2012 from ool3.dyn.optonline.net
show databases;ubuntu@ip-10-151-4-222:~$ show databases;
My question is, why is not being interactive like I thought it would? I should say the expected results was a mysql connection or at least a mysql prompt. But I just get that. Am I doing something wrong?