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 10-06-2016, 07:46 AM
hooknife hooknife is offline
Registered User
 
Join Date: Mar 2007
Posts: 34
SecureCRT not processing script correctly (maybe)

Please be kind - I'm a 100% scripting amateur.

I'm using a network simulation tool from Cisco called VIRL (Virtual Internet Routing Lab). Withing VIRL you create virtual routers and connect to them via an external client. In my case it's SecureCRT. VIRL also allows you send commands back to SecureCRT when you connect to each router.

Here is the command I'm sending to SecureCRT from VIRL.

/SCRIPT "Z:\Dropbox on Host\CCIE\VIRL\COMBO.vbs" /N %t /T /ARG %r /SSH2 /P %p %h /L guest /PASSWORD guest

This is what the command is supposed to do.

1) Create individual tabs for each router
2) SSH to a jumpbox and log into it
3) Once connected, telnet to the individual management IP addresses of each router and login using the username and password of "guest". The management IP addresses are sent to SecureCRT using the above command.


This all works great when I connect to one router and at time withing VIRL. If I select multiple routers and connect, SecureCRT does everything correct except it telnet to the same router in ever tab. You can see in the attached picture that all the sessions are to the same router (10.255.0.114).


Here is the console debug within VIRL that shows the management IPs for each router being sent to SecureCRT.

Opening External Terminal: C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.exe /SCRIPT "Z:\Dropbox on Host\CCIE\VIRL\COMBO.vbs" /N iosv-2 /T /ARG telnet 10.255.0.113 /SSH2 /P 10001 10.1.100.102 /L guest /PASSWORD guest
Opening External Terminal: C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.exe /SCRIPT "Z:\Dropbox on Host\CCIE\VIRL\COMBO.vbs" /N iosv-1 /T /ARG telnet 10.255.0.112 /SSH2 /P 10001 10.1.100.102 /L guest /PASSWORD guest
Opening External Terminal: C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.exe /SCRIPT "Z:\Dropbox on Host\CCIE\VIRL\COMBO.vbs" /N iosv-3 /T /ARG telnet 10.255.0.114 /SSH2 /P 10001 10.1.100.102 /L guest /PASSWORD guest

Here is my script that is referenced in the command that is sent back to SecureCRT from VIRL.

crt.Screen.Send vbcr
crt.Screen.WaitForString "$"
crt.Screen.Send crt.Arguments.GetArg(0) & vbcr

Sub Main()

' turn on synchronous mode
crt.Screen.Synchronous = True

' send carriage return
crt.Screen.Send VbCr

' login name
crt.Screen.WaitForString "Username:"
crt.Screen.Send "cisco" & VbCr

' password
crt.Screen.WaitForString "Password:"
crt.Screen.Send "cisco" & VbCr

' turn off synchronous mode
crt.Screen.Synchronous = False

End Sub
Attached Images
File Type: jpg screenshot1.jpg (429.6 KB, 208 views)
Reply With Quote
  #2  
Old 10-06-2016, 10:39 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,024
Hi hooknife,

And I'm a 100% VIRL/Cisco amateur, so bear with me.

Quote:
This all works great when I connect to one router and at time withing VIRL. If I select multiple routers and connect, SecureCRT does everything correct except it telnet to the same router in ever tab. You can see in the attached picture that all the sessions are to the same router (10.255.0.114).
Is this the complete COMBO.vbs script?

What is the process involved in selecting multiple routers and connecting?


I can see what the problem is. It's processing all three command-lines and retaining *only* the last ARG (telnet 10.255.0.114) when it makes all three connections, but I'm not sure what/where the loop is occurring that allows it to interpret the three unique command-lines.

So the execution needs to be:
Create command-line
Connect
Create command-line
Connect
Create command-line
Connect


Instead it is doing:
Create command-line
Create command-line
Create command-line
Connect
Connect
Connect


And in that case, unfortunately, it has only the last argument for the connection.
__________________
Thanks,
--Brenda

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

Last edited by bgagnon; 10-06-2016 at 11:55 AM.
Reply With Quote
  #3  
Old 10-06-2016, 11:07 AM
hooknife hooknife is offline
Registered User
 
Join Date: Mar 2007
Posts: 34
Please take a look at the post I created on Cisco VIRL's forum - https://learningnetwork.cisco.com/message/581677#581677 You select multiple routers in the VIRL GUI using "Control + mouse left click" then right clicking and pressing connect. You can see the process within the pictures listed in my VIRL forum post.

Yes, this is how it should work.

So the execution needs to be:
Create command-line
Connect
Create command-line
Connect
Create command-line
Connect

Any ideas how I could troubleshoot this issue?

Also, I wanted to direct you to another post you helped with regarding the creation of sessions when using VIRL and SecureCRT. Just thinking it might help give you further understanding.

https://forums.vandyke.com/showthread.php?t=12170

Last edited by hooknife; 10-06-2016 at 11:15 AM.
Reply With Quote
  #4  
Old 10-06-2016, 11:55 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,024
Hi hooknife,

Unfortunately, I do not see that the Cisco mechanism allows any way for you to add a pause between each execution of the command-line. It may be better to actually connect within the script so you have more control over that timing but I do not know if this mechanism would support that due to the substitution variables it needs to pass to the script.

In the script, you might try assigning that ARG to a variable instead to see if that allows it to retain the "uniqueness of each IP":

strMyArg = crt.Arguments.GetArg(0)
crt.Screen.Send vbcr
crt.Screen.WaitForString "$"
crt.Screen.Send strMyArg & vbcr


I have added this thread to a feature request in our product enhancement database to add a method for passing arguments on command-line to script or tab rather than application. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include "Feature Request - Forum Thread #12501" in the subject line or use this form from the support page of our website.

The other forum post you made in our forums is not that helpful. I would expect a single connection to always succeed because you are only using one instance of SecureCRT. In the case of multiple connections, you are instantiating SecureCRT.exe multiple times.
__________________
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 06:42 PM.