【发布时间】:2018-01-29 15:34:40
【问题描述】:
我正在从 Windows 机器自动 ssh 登录到 Linux 服务器。它是通过putty.exe 客户端完成的。
Const WshRunning = 0
Dim UserName
Dim Passwrd
IP = "192.20.30.40"
UserName = "someuser"
Passwrd = "somepass"
Set shell = WScript.CreateObject("WScript.Shell")
pcmd = "putty.exe -ssh" & " " & UserName & "@" & IP & " -pw" & " " & Passwrd & " -m ""commands.txt"""
Set exec = shell.Exec(pcmd)
Do While exec.Status = WshRunning
WScript.Sleep 100
Loop
Set pout = exec.StdOut
strOutput = exec.StdOut.ReadAll()
WScript.StdOut.Write(strOutput)
WScript.Echo(strOutput)
但我无法获得在 Linux 服务器上执行的命令的输出。如何在 VBScript 变量中输出这些 Linux 命令?
有一些关于 Plink 工具的建议。但它不允许基于自动密码的 ssh。
【问题讨论】: