VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Do show command in Cisco cli (https://forums.vandyke.com/showthread.php?t=12643)

retsam111 03-21-2017 10:01 AM

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#

bgagnon 03-21-2017 11:18 AM

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 & ">"

Casey 03-21-2017 01:18 PM

Perhaps try replacing vbCr with vbCrLf as your delimiter?

Casey 03-22-2017 07:29 AM

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.

retsam111 03-22-2017 08:46 AM

The delimiter was it, I changed it to vbCRLf and it worked. Thanks for the help.


All times are GMT -6. The time now is 10:17 AM.