Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-21-2017, 10:01 AM
retsam111 retsam111 is offline
Registered User
 
Join Date: Mar 2017
Posts: 2
Do show command in Cisco cli

I'm trying to check for a specific configuration for each interface.
After I log in with telnet, this is my script
' When telnet session is opened successfully do the following

' Push the cli commands to the device
crt.Screen.Synchronous = True
strCommand = "show interface status" & vbCr
crt.Screen.Send strCommand
crt.Screen.WaitForString strCommand
screenOut = crt.Screen.ReadString("#")

tempArray = Split(screenOut, vbcr)
For i = 2 to Ubound(tempArray)-1
interfaces = Split(tempArray(i))
strCommand = "show run interface "& interfaces(0) & vbCr
crt.Screen.Send strCommand
crt.Screen.WaitForString strCommand
screenOut = crt.Screen.ReadString("#")
objStream.WriteLine screenOut
Next

However, strCommand = "show run interface "& interfaces(0) & vbCr doesn't work in the Cisco cli. It shows up as two commands, but it's clearly one line.

Output from Cisco cli
uct-m60mike-desk-1#show interface status

Port Name Status Vlan Duplex Speed Type
Gi0/1 notconnect 2002 auto auto 10/100/1000BaseTX
Gi0/2 notconnect 2002 auto auto 10/100/1000BaseTX
Gi0/3 notconnect 2002 auto auto 10/100/1000BaseTX
Gi0/4 notconnect 2002 auto auto 10/100/1000BaseTX
Gi0/5 notconnect 2002 auto auto 10/100/1000BaseTX
Gi0/6 notconnect 2002 auto auto 10/100/1000BaseTX
Gi0/7 notconnect 2002 auto auto 10/100/1000BaseTX
Gi0/8 notconnect 2002 auto auto 10/100/1000BaseTX
Gi0/9 UCT-m50-l2-1 connected trunk a-full a-1000 10/100/1000BaseTX
Gi0/10 disabled 1 auto auto Not Present
uct-m60mike-desk-1#show run interface
% Incomplete command.

uct-m60mike-desk-1#Gi0/1
^
% Invalid input detected at '^' marker.

uct-m60mike-desk-1#
Reply With Quote
  #2  
Old 03-21-2017, 11:18 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hi retsam111,

I don't see anything wrong with your code either.

I would just suggest you add a MsgBox() before sending strCommand and enclose it in angle brackets so you can see what's being sent for sure:

MsgBox "<" & strCommand & ">"
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 03-21-2017, 01:18 PM
Casey Casey is offline
Registered User
 
Join Date: Oct 2011
Posts: 114
Perhaps try replacing vbCr with vbCrLf as your delimiter?
Reply With Quote
  #4  
Old 03-22-2017, 07:29 AM
Casey Casey is offline
Registered User
 
Join Date: Oct 2011
Posts: 114
I did a little poking around and it seems that your script will start working if:

1) You change the vbCr to vbCrLf on just one line:

Old Line:
Code:
tempArray = Split(screenOut, vbCr)
New Line:
Code:
tempArray = Split(screenOut, vbCrLf)
2) Remove "objStream.WriteLine screenOut" from the end. I'm guessing that is just an extra line that accidentally slipped in when you were creating your test code for us.


* I'm running this from a Windows PC, I'm not sure what you're on.
Reply With Quote
  #5  
Old 03-22-2017, 08:46 AM
retsam111 retsam111 is offline
Registered User
 
Join Date: Mar 2017
Posts: 2
The delimiter was it, I changed it to vbCRLf and it worked. Thanks for the help.
Reply With Quote
Reply

Tags
cisco , show run

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 04:34 AM.