【发布时间】:2014-10-17 10:22:08
【问题描述】:
我想使用 Excel VBA/VB 脚本自动执行以下步骤。 这是我手动执行的操作列表
第一步:登录winscp。
- 主机名:example.ash.pwj.com
- 端口:22
- 用户名:xxx 密码:yyyy
- 文件协议:SFTP
使用 Winscp 将名为“testFile”的文件从本地机器传输到 Unix 服务器中的目录 (该目录有一个python脚本'connector.py')
第二步:打开腻子。
- 目标主机名:example.ash.pwj.com
- 端口:22
- 连接类型:SSH
- 使用凭据登录。
Step3:调用目录下的python脚本。
python connector.py argument1 argument2 argument3
例如:python connector.py testFile example2.ash.pwj.com 123
我必须使用 Excel VBA/VBScript 在 putty 中处理 WINSCP 文件传输和调用 python 脚本。
这是我的代码:
Set sh = CreateObject("WScript.Shell")
sh.Run "pscp -pw yyyy C:\Users\abc\testFile xxx@example.ash.pwj.com:/home/test/dir", 0, True
sh.Run "plink.exe -pw yyyy xxx@example.ash.pwj.com python /home/test/dir/connector.py testFile example2.ash.pwj.com 514", 0, True
【问题讨论】:
-
@will 并不是真正的重复,因为他想在具有不同操作系统的不同主机上运行 python 脚本。
-
这一切都可以在被调用的 python 脚本中完成,不是吗?
-
@will 在远程 (Unix) 主机上调用 Python 脚本。我们不知道 Windows 机器上是否安装了 Python 解释器,或者 OP 是否可以安装一个。