CrewXp Posted October 23, 2007 Share Posted October 23, 2007 (edited) Hey, I've searched around the forums for help, but I just can't seem to get it to work. I'm trying to ssh to my server, login, and then have it send some commands... However, It doesn't seem to return the result of the command I send If you look at the code, It detects the text it's supopsed to, then it's supposed to send 'n' for no. When it gets to command prompt (after Sleep 1000), I send ls (to list directories). However, I never get a second message box giving me the output. I use plink, putty in command line form. #include <Constants.au3> $hostname="mysite.com" Dim $szIPADDRESS = TCPNameToIP($hostname) $PID = Run(@comspec & " /c C:\Users\CrewXp\Downloads\plink.exe " &$hostname& " -pw mypass -l crewxp -ssh ","",@SW_MAXIMIZE,$STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD) DIM $sSTDOUT = "", $sSTDERR = "" Do Sleep(2000) $OUT = StderrRead($PID) Msgbox(0,"",$OUT) If Stringinstr($OUT,"The server's host key") Then StdinWrite($PID,"n") Sleep(2000) StdinWrite($PID,"ls") EndIf Until Not ProcessExists($PID) Edited October 23, 2007 by CrewXp Link to comment Share on other sites More sharing options...
cpuobsessed Posted November 9, 2007 Share Posted November 9, 2007 (edited) Hey, I've searched around the forums for help, but I just can't seem to get it to work. I'm trying to ssh to my server, login, and then have it send some commands... However, It doesn't seem to return the result of the command I send If you look at the code, It detects the text it's supopsed to, then it's supposed to send 'n' for no. When it gets to command prompt (after Sleep 1000), I send ls (to list directories). However, I never get a second message box giving me the output. I use plink, putty in command line form. #include <Constants.au3> $hostname="mysite.com" Dim $szIPADDRESS = TCPNameToIP($hostname) $PID = Run(@comspec & " /c C:\Users\CrewXp\Downloads\plink.exe " &$hostname& " -pw mypass -l crewxp -ssh ","",@SW_MAXIMIZE,$STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD) DIM $sSTDOUT = "", $sSTDERR = "" Do Sleep(2000) $OUT = StderrRead($PID) Msgbox(0,"",$OUT) If Stringinstr($OUT,"The server's host key") Then StdinWrite($PID,"n") Sleep(2000) StdinWrite($PID,"ls") EndIf Until Not ProcessExists($PID) Edited November 9, 2007 by cpuobsessed Link to comment Share on other sites More sharing options...
cpuobsessed Posted November 9, 2007 Share Posted November 9, 2007 Have you tried using the send command? Link to comment Share on other sites More sharing options...
Descention Posted September 29, 2008 Share Posted September 29, 2008 (edited) Here's what i did, though it doesn't work completely yet and it MUST be compiled as a console application: #include <Constants.au3> HotKeySet('`',"_read"); hit this button to read your input after hitting enter(tilde button) $user = "";username $pass = "";password $host = "";host $plink = Run("plink.exe -P 22 -l "&$user&" -pw "&$pass&" -ssh "&$host,@ScriptDir, @SW_HIDE, $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD) $read = False while 1 $msg = StdoutRead($plink) if @error then ExitLoop if $msg <> "" Then ConsoleWrite($msg) EndIf if $read Then StdinWrite($plink,ConsoleRead()) $read=False EndIf sleep(25) WEnd StdioClose($plink) func _read() $read = True EndFunc Edited September 29, 2008 by Descention Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now