VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   If condition in vbs (https://forums.vandyke.com/showthread.php?t=14268)

ananthaa2000 08-22-2020 09:19 AM

If condition in vbs
 
Hi

I seek your guidance for if condition for below script

Below script for login multiple nodes and execute some commands

When I execute below script in SecureCRT ,when the node asks "(yes/no)? " then it send Yes then next line is password and but it is not sending ..it is waiting for password

*************************************************************

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:/vblist.txt")

Do Until f.AtEndOfStream

crt.Screen.Synchronous = True
crt.Screen.Send "ssh -l admin " & f.ReadLine & VbCr
crt.Screen.WaitForString "(yes/no)?"
crt.Screen.send "yes" & VbCr
crt.Screen.WaitForString "password:"
crt.Screen.Send "password" & VbCr
crt.Screen.WaitForString "#"
crt.Screen.Send "sh clock" & VbCr
crt.Screen.WaitForString "#"
crt.Screen.Send "exit" & VbCr
crt.Screen.WaitForString "closed." & VbCr
crt.Screen.Synchronous = False


Loop

f.Close

*************************************************************

bgagnon 08-23-2020 06:41 PM

Hi ananthaa2000,

What is the password prompt?

Is it a lower case 'p'?

If not, you are not going to match it. That's why, you will find, where we include such things in SecureCRT's GUI (such as in Logon Actions), we "expect" all but the first character to allow for either Password/password to be the prompt.

If you "wait for" 'assword:', what are the results?

ananthaa2000 09-05-2020 12:07 PM

yes this is lower char p

bgagnon 09-08-2020 08:49 AM

Hi ananthaa2000,

Are you always faced with the inquiry that requires the yes/no response?

If not, then you must put that in an If statement.

Please post a screenshot (see info here about posting graphics in the forums) showing the interaction in the terminal window and where the script gets "hung".

ananthaa2000 09-08-2020 09:45 AM

Not always ..sometimes..OK i will try to use If in that.Thanks

Moreover can you guide me how to make this script in Automation ?

bgagnon 09-08-2020 10:30 AM

Hi ananthaa2000,

Have you ever considered using dependent session functionality in place of the "old method" of running ssh host from the terminal window?

Changes in SecureCRT 7.1 (Beta 1) -- February 26, 2013
------------------------------------------------------
New features:

  • Added support for dependent sessions so that a connection can be made to a jump host or SSH gateway before the session is connected.

However, if you have configured your SSH session to the jumphost so that all the initial authentication is taken care of, then you should be able to make this script the logon script in the Connection / Logon Actions category of Session Options.


All times are GMT -6. The time now is 02:00 PM.