Xshell Forum

Simple login script

Last post: Wednesday, January 16, 2013 4:50 PM by Rob, 3 reply

 
Tuesday, January 15, 2013 10:05 AM - Mags

Simple login script

 
I am trying to login to a machine and run a command but it fails, first I get a warning:

Session::timeout!

Then it logs me in, but it does not run the command "sudo bash"

Here it is:

Sub Main
' *** Connect the session ***
xsh.Session.Open "/s C:\Users\Admin\AppData\Roaming\NetSarang\Xshell\Sessions\mine.xsh"
xsh.Screen.Send "sudo bash"
xsh.Screen.Send VbCr
End Sub

Program Ver. : Xshell 4
Tuesday, January 15, 2013 3:42 PM - Support

Re: Simple login script

 
First, try upgrading to the latest by going to Help > Check for updates.

Edit script like the following:

xsh.Session.Open "/s C:\Users\Admin\AppData\Roaming\NetSarang\Xshell\Sessions\mine.xsh"
xsh.Screen.WaitForString "login: "
xsh.Screen.Send "sudo bash"
xsh.Screen.Send VbCr

Please let us know if we can be of further assistance.

---
Technical Support
Wednesday, January 16, 2013 8:20 AM - Mags

Re: Simple login script

 
Hi .. this works if I do:

xsh.Session.Open "/s C:\Users\Admin\AppData\Roaming\NetSarang\Xshell\Sessions\mine.xsh"
xsh.Screen.WaitForString "username@server:~$"
xsh.Screen.Send "sudo bash"
xsh.Screen.Send VbCr

Thank you ...

now I am try to do that in several windows, as in:

xsh.Session.Open "/s C:\Users\Admin\AppData\Roaming\NetSarang\Xshell\Sessions\mine1.xsh"
xsh.Screen.WaitForString "username@server1:~$"
xsh.Screen.Send "sudo bash"
xsh.Screen.Send VbCr

xsh.Session.Open "/s C:\Users\Admin\AppData\Roaming\NetSarang\Xshell\Sessions\mine2.xsh"
xsh.Screen.WaitForString "username@server2:~$"
xsh.Screen.Send "sudo bash"
xsh.Screen.Send VbCr


It only works in the first window? Any ideas?

Thanks,

Mags
Wednesday, January 16, 2013 4:50 PM - Rob

Re: Simple login script

 
You can try VB script like this:

xsh.Session.Open "/s C:\Users\Admin\AppData\Roaming\NetSarang\Xshell\Sessions\mine.xsh"
xsh.Session.Open "/s C:\Users\Admin\AppData\Roaming\NetSarang\Xshell\Sessions\mine2.xsh"


Then use Logon Script found under Connection > Logon Scripts. (Xshell to expect certain string and send the text.)
ex. Expect @, Send sudo bash