Code: Select all
Wscript.sleep [time in milliseconds]
Code: Select all
vbstart
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)
set ssh = CreateObject("Chilkat.Ssh")
success = ssh.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
MsgBox ssh.LastErrorText
WScript.Quit
End If
hostname = "192.168.1.108"
port = 22
success = ssh.Connect(hostname,port)
If (success <> 1) Then
MsgBox ssh.LastErrorText
WScript.Quit
End If
ssh.IdleTimeoutMs = 5000
success = ssh.AuthenticatePw("myLogin","myPassword")
If (success <> 1) Then
MsgBox ssh.LastErrorText
WScript.Quit
End If
channelNum = ssh.OpenSessionChannel()
If (channelNum < 0) Then
MsgBox ssh.LastErrorText
WScript.Quit
End If
success = ssh.SendReqExec(channelNum,"ls -la")
If (success <> 1) Then
MsgBox ssh.LastErrorText
WScript.Quit
End If
pollTimeoutMs = 2000
n = ssh.ChannelReadAndPoll(channelNum,pollTimeoutMs)
If (n < 0) Then
MsgBox ssh.LastErrorText
WScript.Quit
End If
success = ssh.ChannelSendClose(channelNum)
If (success <> 1) Then
MsgBox ssh.LastErrorText
WScript.Quit
End If
success = ssh.ChannelReceiveToClose(channelNum)
If (success <> 1) Then
MsgBox ssh.LastErrorText
WScript.Quit
End If
cmdOutput = ssh.GetReceivedText(channelNum,"ansi")
If (cmdOutput = vbNullString ) Then
MsgBox ssh.LastErrorText
WScript.Quit
End If
outFile.WriteLine(cmdOutput)
ssh.Disconnect
outFile.Close
VBEND