Тема: VBScript: Работа с SSH
Добрый день коллеги.
Столкнулся со следующей проблемой.
Необходимо реализовать автоматический backUp коммутаторов HP через tftp сервер.
в инете нарыл 2 библиотеки умеющие работать с ssh Chilkat.Ssh и ActiveXperts.Ssh
Получились вот такие скрипты, но не один из них не работает, помогите разобраться.
1) Вариант
Set objSsh = CreateObject("ActiveXperts.Ssh") ' Create an Ssh instance
objSsh.Host = "10.77.3.207" ' Hostname or IP address of
' remote UNIX/LINUX machine
objSsh.UserName = "admin" ' Login as 'root'
objSsh.Password = "123456"
'objSsh.Port = "22"
objSsh.Command = "copy running-config tftp 10.77.2.90 test.txt" ' Command to execute
objSsh.ScriptTimeOut = 5000 ' Time-out (in milliseconds)
objSsh.Run ' Execute the command now
WScript.Echo "Run: result = " & objSsh.LastError
If objSsh.LastError <> 0 Then
WScript.Echo "Error " & objSsh.LastError
End If
' YES, command has completed
WScript.Echo "StdErr: " & objSsh.StdErr ' Print Standard Output
WScript.Echo "StdOut: " & objSsh.StdOut ' Print Standard Error
WScript.Echo "Ready."2) Вариант
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)
Set ssh = CreateObject("Chilkat.Ssh")
hostname = "10.77.3.207"
port = 22
success = ssh.Connect(hostname,port)
ssh.IdleTimeoutMs = 5000
success = ssh.AuthenticatePw("admin","123456")
channelNum = ssh.OpenSessionChannel()
cmd1 = "copy running-config tftp 10.77.2.90 test.txt"
success = ssh.SendReqExec(channelNum,cmd1)
pollTimeoutMs = 2000
n = ssh.ChannelReadAndPoll(channelNum,pollTimeoutMs)
success = ssh.ChannelSendClose(channelNum)
success = ssh.ChannelReceiveToClose(channelNum)
cmdOutput = ssh.GetReceivedText(channelNum,"ansi")
If (cmdOutput = vbNullString ) Then
'MsgBox ssh.LastErrorText
'WScript.Quit
End If
' Display the remote shell's command output:
outFile.WriteLine(cmdOutput)
' Disconnect
ssh.Disconnect
outFile.CloseЗаранее благодарен за помощь.

