sanchez77 Posted May 12, 2012 Share Posted May 12, 2012 I am using the http://phpseclib.sourceforge.net/ and I able to connect to a Unix prompt and login. After login if I send echo $ssh->exec('pwd'); it returns the directory I am in as it should. but when I send this, a command on the box to change db instances. echo $ssh->write("csession instance1 \n"); It just returns a 1. What does the 1 mean? Second question, how can I show what the prompt is returning? I tried echo $ssh->read('[prompt]'); but it fails, I also tried (with changed values for username@password) $output = $ssh->read('#Password:|username@password:~\$#', NET_SSH2_READ_REGEX); echo $output; and that failed as well. Does anyone know what the 1 means and how I could read the return prompt after sending a command? Thanks, sanchez Quote Link to comment https://forums.phpfreaks.com/topic/262445-ssh2/ Share on other sites More sharing options...
banksreach Posted May 14, 2012 Share Posted May 14, 2012 Looks like you posted this question on the phpseclib support forums: http://www.frostjedi.com/phpbb/viewtopic.php?p=156917#p156917 Do you not know what the prompt is? If so you can do this to figure it out: <?php include('Net/SSH2.php'); $ssh = new Net_SSH2('www.domain.tld'); if (!$ssh->login('username', 'password')) { exit('Login Failed'); } $ssh->setTimeout(5); echo $ssh->read(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/262445-ssh2/#findComment-1345217 Share on other sites More sharing options...
sanchez77 Posted May 14, 2012 Author Share Posted May 14, 2012 Thanks for your help. My post is also on Frost Jedi. But when I tried the code you recommended i received this error in the log for the timeout call: [14-May-2012 14:40:57 UTC] PHP Fatal error: Call to undefined method Net_SSH2::setTimeout() in C:\inetpub\test\testssh6.php on line 8 if I comment that out, I receive this: [14-May-2012 14:36:21 UTC] PHP Warning: Missing argument 1 for Net_SSH2::read(), called in C:\inetpub\test\testssh6.php on line 9 and defined in C:\inetpub\test\phpseclib0.2.2\Net\SSH2.php on line 1768 [14-May-2012 14:36:21 UTC] PHP Notice: Undefined variable: expect in C:\inetpub\test\phpseclib0.2.2\Net\SSH2.php on line 1780 Thanks, sanchez Quote Link to comment https://forums.phpfreaks.com/topic/262445-ssh2/#findComment-1345329 Share on other sites More sharing options...
sanchez77 Posted May 14, 2012 Author Share Posted May 14, 2012 timeout error failed because I did not have the latest SVN. Fixed that by downloading the latest. Quote Link to comment https://forums.phpfreaks.com/topic/262445-ssh2/#findComment-1345389 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.