Cisco MDS login and show commands (wodSSH / wodSSH.NET)
I'm trying to write a basic VB program using Visual Studio 2005.
The goal is to telnet or SSH to a Cisco MDS Fiber Channel Switch, and run some basic commands, which will eventually be sent to a text file.
This is what I see when I telnet or SSH using SecureCRT.
--------- Start Paste ----------------
MDS-Top login: admin
Password:
Cisco Storage Area Networking Operating System (SAN-OS) Software
TAC support: http://www.cisco.com/tac
Copyright (c) 2002-2005, Cisco Systems, Inc. All rights reserved.
The copyrights to certain works contained herein are owned by
other third parties and are used and distributed under license.
Some parts of this software are covered under the GNU Public
License. A copy of the license is available at
http://www.gnu.org/licenses/gpl.html.
MDS-Top# show version
Cisco Storage Area Networking Operating System (SAN-OS) Software
TAC support: http://www.cisco.com/tac
Copyright (c) 2002-2005, Cisco Systems, Inc. All rights reserved.
The copyrights to certain works contained herein are owned by
other third parties and are used and distributed under license.
Some parts of this software are covered under the GNU Public
License. A copy of the license is available at
http://www.gnu.org/licenses/gpl.html.
Software
BIOS: version 1.1.0
loader: version 1.2(2)
kickstart: version 2.1(1b)
system: version 2.1(1b)
BIOS compile time: 10/24/03
kickstart image file is: bootflash:/m9200-ek9-kickstart-mz.2.1.1b.bin
kickstart compile time: 7/19/2005 20:00:00 [07/26/2005 17:29:49]
system image file is: bootflash:/m9200-ek9-mz.2.1.1b.bin
system compile time: 7/19/2005 20:00:00 [07/26/2005 17:49:06]
Hardware
cisco MDS 9216 ( 2x1GE IPS, 14x1/2Gbps FC/Supervisor )
Intel(R) Pentium(R) III CPU - with 964000 kB of memory.
Processor Board ID JAB0941037A
bootflash: 500736 blocks (block size 512b)
slot0: 0 blocks (block size 512b)
MDS-Top kernel uptime is 8 days 20 hours 5 minute(s) 46 second(s)
Last reset at 322491 usecs after Tue Jan 17 23:20:55 2006
Reason: Reset Requested by CLI command reload
System version: 2.1(1b)
Service:
MDS-Top#
--------- End Paste ---------
Presently this the code I'm using
------- Start Paste ---------
Public Class Form1
Dim WithEvents Ssh1 As WeOnlyDo.Client.SSH
Public SSHCommand As String = show version
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Ssh1 = New WeOnlyDo.Client.SSH() ' Initialize new instance
Ssh1.Blocking = True
Ssh1.Login = admin ' Set your login/username
Ssh1.Password = password ' Set your password
Ssh1.Encryption = WeOnlyDo.Client.SSH.EncryptionMethods.Auto ' Any encryption is ok
' Ssh1.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.Telnet
Ssh1.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSH1 ' Set SSH version
Ssh1.Prompt = MDS-Top#
Ssh1.Hostname = 1.1.1.1
Ssh1.Connect( 1.1.1.1 ) ' Connect, finally. Now wait for Connected event to occur
'Ssh1.WaitFor( MDS-Top# , 5)
'Ssh1.Execute( show version , MDS-Top# , 5)
'Ssh1.Execute( show version & Chr(10), # , 5)
TextBox1.Text = Ssh1.Receive
End Sub
End Class
--------- End Paste ----------
When I run it (as it stands right now) I get all of the output upto an d including MDS-Top# . However when I uncomment any of the Ssh1.Execute commands I get a timeout due to in activity.
If I attempt to add Ssh1.command= show version & vblf It tells me that the stdin: line is not tty
What the heck am I missing? It probably easy, but I haven't messed around with VB for a couple of years and the old brain doesn't ramp up as quickly as it used to.
Any help is appreciated.
Thanks
VBRookie
Re: Cisco MDS login and show commands
VBRookie,
try something like this:
[code]Ssh1.Connect( 1.1.1.1 ) ' Connect, finally. Now wait for Connected event to occur
Ssh1.WaitFor( MDS-Top# , 5)
Ssh1.Execute( show version & Chr(10), MDS-Top# , 5)[/code]
that must work. Otherwise, you can also call
Ssh1.Send( show version & chr(10))
and then call Ssh1.Receive - that's also a way to go.
Kreso
Re: Cisco MDS login and show commands
Kreso,
I tried both of these with different results.
[code]
Ssh1.WaitFor( MDS-Top# , 5)
ssh1.execute( show version & Chr(10), MDS-Top# , 5)
[/code]
The execute command timed out due to inactivity
[code]
Ssh1.WaitFor( MDS-Top# , 5)
Ssh1.Send( show version & chr(10))
TextBox1.Text = Ssh1.Receive
[/code]
This one didn't return any data to Textbox1.
This device is on my local LAN so the response should be almost immediate.
Any thoughts?
VBRookie
Re: Cisco MDS login and show commands
Maybe it did. Maybe it was just newline? You should call it more than once until you see what is actually returned, and then tweak execute method to fit returned data.
Perhaps you never got Execute to returned because prompt was never received? What if 'press any key...' was shown?
Also, add to TextBox, don't overwrite it.
Re: Cisco MDS login and show commands
Maybe it did. Maybe it was just newline? You should call it more than once until you see what is actually returned, and then tweak execute method to fit returned data.
Perhaps you never got Execute to returned because prompt was never received? What if 'press any key...' was shown?
Also, add to TextBox, don't overwrite it.
Talk about Tech Support
[:wink:]
Any idea about the inactivity timeout?
And a really stupid question, how to you add to the textbox?
VBRookie
Re: Cisco MDS login and show commands
Ignore inactivity timeout for now. First determine what's received, then tweak Execute method to catch that received data. Once you do it, you will not worry about timeout since planned and expected data/prompt will be returned.
As for adding to textbox,
TextBox1.Text = TextBox1.Text + Ssh1.Receive