Question about SSH ActiveX Control (General questions)
I am evaluating the SSH control for a project, but one of the things I need to be able to do is use it to log into a Cisco Wireless Controller using SSH and execute one or more commands. I have tried using several examples I found in the forums without success. Using the standard example, I can connect to a Unix box without any problems, but the Cisco WLC keeps giving me fits. I think the biggest problem is the fact that the WLC has a secondary login prompt, and I just don't know how to make the SSH control do what I want it to do. I would appreciate any help that you can provide.
Here is the output of my manually logging into the WLC, and this is after running putty from the command line with parameters like this:
putty -l admin -pw abc123 10.10.10.10
=====================================================================
Using username admin .
(Cisco Controller)
User: admin <--- secondary login
Password:****** <--- secondary pw
(Cisco Controller) >show inv
Switch Description............................... Cisco Controller
Machine Model.................................... AIR-WLC4402-50-K9
Serial Number.................................... xxxxxxxxxxx
Burned-in MAC Address............................ xx:xx:xx:xx:xx:xx
Crypto Accelerator 1............................. Absent
Crypto Accelerator 2............................. Absent
Power Supply 1................................... Absent
Power Supply 2................................... Present, OK
(Cisco Controller) >logout
The system has unsaved changes.
Would you like to save them now? (y/N)
=====================================================================
Re: Question about SSH ActiveX Control
Hi Josh,
Maybe this will help:
[code]
Set ssh1 = New wodTelnetDLXCom
ssh1.HostName = ylour_hostname
ssh1.Blocking = True
ssh1.Login = your_login
ssh1.Password = your_password
'ssh1.StripANSI = True
ssh1.Connect
ssh1.WaitFor ( User: )
ssh1.Send secondary login + vbCrLf
ssh1.WaitFor ( Password: )
ssh1.Send secondary pw + vbCrLf
Debug.Print ssh1.Receive
Debug.Print ssh1.Receive
Debug.Print ssh1.Receive
[/code]
If problem persist please change vbCrLf with vbLf. Also you can try to add one space after User: (ssh1.WaitFor ( User: )) and Password: (ssh1.WaitFor ( Password: )) under WaitFor Method lines.
Let us know how it goes.
Regards,
Drazen
Re: Question about SSH ActiveX Control
Ok, finally got this working. Haven't spent a lot of time on it yet, but I haven't had a bunch of time either. I was able to make this work by modifying the sample script provided with the control and I've changed the exec section to look like this:
[code]
set ssh = CreateObject( WeOnlyDo.wodSSHCom.1 )
ssh.Login = Request.Form( login )
ssh.Password = Request.Form( password )
ssh.Hostname = Request.Form( hostname )
ssh.Blocking = 1
ssh.Protocol = Request.Form( protocol )
Dim p
p = Request.Form( port )
ssh.Port = p
ssh.Timeout = 10
ssh.Connect
ssh.WaitFor ( User: )
ssh.Send secondary_username + vbLf
ssh.WaitFor ( Password: )
ssh.Send secondary_password + vbLf
ssh.WaitFor ( > )
ssh.Send config paging disable + vbLf
ssh.WaitFor ( > )
ssh.Send show inv + vbLf
' now we read as long as there's something to read
On Error Resume next
ssh.Timeout = 2
Dim a
a = something
while a <> ' iow while connected
a =
a = ssh.Receive
if a <> then
resp = resp & a
end if
wend
[/code]
This works and gives me output in the textarea like this:
[code]
show inv
Burned-in MAC Address............................ xx:xx:xx:xx:xx:xx
Crypto Accelerator 1............................. Absent
Crypto Accelerator 2............................. Absent
Power Supply 1................................... Absent
Power Supply 2................................... Present, OK
NAME: Chassis , DESCR: Chassis
PID: AIR-WLC4404-100-K9, VID: V02, SN: xxxxxxxxxxx
(Cisco Controller) >
[/code]
However, if I send multiple commands, I only get the output from the last command and I can't seem to figure out how to capture the rest of the output. I've tried adding in some extra ssh.Receive's and when I do that, I get WeOnlyDo.wodSSHCom.1 (0x800A05B4) The current connection has timeout. messages. Ideally, I'd like to capture every drop of output from the initial login until I'm completely done. I would appreciate it if someone could point me in the right direction. Thanks!
Re: Question about SSH ActiveX Control
Josh,
When you use WaitFor method, it strips everything received from the buffer. That means that when you call Receive method, the string received by WaitFor won't be shown (since it's no longer in the buffer).
You should use WaitFor as a function. I.e:
dim a as string
a=ssh.WaitFor( prompt )
and then append the next waitfor to a etc.
This way you will receive everything.
Can you try this?
Regards,
Damba
Re: Question about SSH ActiveX Control
Perfect! That worked like a charm. Now I just need to finish my proof of concept so I can get this thing wrapped up. Thanks again for your help!