Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-22-2020, 09:19 AM
ananthaa2000 ananthaa2000 is offline
Registered User
 
Join Date: Aug 2020
Posts: 3
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

*************************************************************
Reply With Quote
  #2  
Old 08-23-2020, 06:41 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,481
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?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 09-05-2020, 12:07 PM
ananthaa2000 ananthaa2000 is offline
Registered User
 
Join Date: Aug 2020
Posts: 3
yes this is lower char p
Reply With Quote
  #4  
Old 09-08-2020, 08:49 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,481
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".
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 09-08-2020, 09:45 AM
ananthaa2000 ananthaa2000 is offline
Registered User
 
Join Date: Aug 2020
Posts: 3
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 ?
Reply With Quote
  #6  
Old 09-08-2020, 10:30 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,481
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.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 11:03 AM.