【发布时间】:2016-12-07 12:51:34
【问题描述】:
我正在尝试从 VBA 运行 shell 命令并将输出保存到 csv 文件中。以下是我正在使用的代码:
Dim wsh as Object
Set wsh = VBA.CreateObject("WScript.Shell")
plink_path="C:\plink.exe"
key_path="putty key path"
pass_query="select * from test"
command1 = Replace(plink_path & " hadoop@11.11.11.11 -i " & key_path & " mysql -uuser -ppass -e 'use radar;" & pass_query & "'", Chr(10), " ")
wsh.Run command1 & ">E:/anurag.csv", 0, True
但我无法查看 E 盘中的输出文件。当我从cmd 提示符手动运行上述命令时,我确实在 E 驱动器中得到了输出。
【问题讨论】:
-
如果它将输出发送到 STDOUT,something like this might 很有用。
标签: vba cmd io-redirection wsh