0

我有一个 VBScript,它可以 Telnet 到 Linux 设备,我想查看可用内存。以下命令产生“无效的过程调用或参数”错误。

WshShell.SendKeys"df /mnt/cf | awk '/mnt/{print$2}'"

如果我手动 telnet 进入设备并使用相同的命令,这将有效。有什么建议吗?

到目前为止的代码:

Dim WshShell

Set WshShell = CreateObject("WScript.Shell")
WshShell.run"cmd" 
'*** open command window *** 
WScript.Sleep 250 WshShell.SendKeys("{Enter}") 
WshShell.SendKeys"telnet 10.13.2.2 -f VBSmemSize.txt" 
WshShell.SendKeys("{Enter}") 
WScript.Sleep 2000 
WshShell.SendKeys"root" 
WshShell.SendKeys("{Enter}") 
WScript.Sleep 1500 
WshShell.SendKeys"password" 
WshShell.SendKeys("{Enter}") 
WScript.Sleep 1500 
WshShell.SendKeys"df /mnt/cf |awk '/mnt/{print$2}'" 
WshShell.SendKeys("{Enter}")
4

2 回答 2

1

我对它不太熟悉,但这是否有效:

Dim oShell  

set oShell = wscript.createObject("wscript.shell") 

oShell.Run "df /mnt/cf | awk '/mnt/{print$2}'"

Set oShell = Nothing   
于 2012-05-09T17:48:21.753 回答
0

错误字符是'{',这是一个特殊字符。您可以使用“{}”来包围这些特殊字符。例如,

WshShell.SendKeys"df /mnt/cf |awk '/mnt/{{}print$2{}}'" 
于 2020-04-23T03:34:34.710 回答