English 中文(简体)
如何在VB. 文本中使用AWK?
原标题:What is correct syntax to use AWK in VBScript?
  • 时间:2012-05-09 17:43:30
  •  标签:
  • vbscript

I have a VBScript which Telnets into a Linux device and I would like to see the available memory. The following command produces an "Invalid procedure call or argument" error.

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

如果我用人工电话进入该装置,并使用同一指挥系统,该装置就可运行。 任何建议?

至今为止的法典:

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}")
问题回答

我不熟悉这项工作:

Dim oShell  

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

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

Set oShell = Nothing   

The error character is { , this is a special one. You could use {} to surround with those special character. For example,

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




相关问题
What approach should I use to test a VBScript?

I ve been asked to help out with a project which has made extensive use of VBScript to process a whole bunch of text files and generate certain outputs - sanitized files, SQL entries etc.. The script ...

Unable to call c# code from vbscript - ActiveX error

I am trying to call a method I have written in C# from VBScript. I have followed just about all of the instructions I can find on the web and am still having problems. Specifically I am getting Error:...

How to set delay in vbscript

How to set delay in vbscript? WScript.Sleep(100) does not work on Windows XP, Vista.

Using Classes in a Dictionary in Classic ASP

I usually do C# but have inherited a classic ASP project. I have defined a class: Class clsPayment Public Name End Class Set objPayment = New clsPayment objPayment.Name = "...

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

Problem casting field when querying spreadsheet

I am trying to query an .xls spreadsheet with VBScript, but I have run into an issue when trying to cast a field. I connect to the spreadsheet like this. Set objConnection = CreateObject("ADODB....

热门标签