如何放置 unix 命令 - 在 VBScript 中将文件从 Windows 复制到 Unix 目录/从 Unix 复制到 Windows?
How to place unix commands - copy files from Windows to Unix directory/ Unix to Windows in VBScript?
我不确定如何将 Unix 命令放入 VBScript 文件。
我正在尝试用 VBScript 编写代码,我们可以在其中将我们的文件从 Windows 文件夹复制到 Unix 目录。
在我们的Unix目录下写入文件需要用户名和密码。
我摸索了一下,发现我们可以这样使用SCP命令来拷贝文件:
scp d:/folders/hello.txt /abc_st/batchrepo/inbox
# I am still exploring for copying files from Unix to Windows
而对于 Username/Password,我发现我们可以在 scp 命令之前使用如下所示的 sshpass 命令:
sshpass -p "your password"
# I still have to explore on this as I cant see the place for username.
有人可以建议我如何将这些命令放入 VBScript 文件中。
我会将此 VBScript 放入 HTML 文件中。
谢谢
VBScript 本身不支持 SSH,因此您需要某种 scp
实用程序来将文件从 Windows 主机复制到 Unix 主机,例如 pscp.exe
from the PuTTY suite, or the ssh package in Cygwin。
假设您使用的是 pscp.exe
,您可以 运行 客户端通过这样的 shelling out:
Set sh = CreateObject("WScript.Shell")
sh.Run "C:\path\to\pscp.exe -pw PASS D:\folders\hello.txt unixhost:/abc_st/batchrepo/inbox", 0, True
如果路径包含空格,请务必用引号引起来:
Function qq(str) : qq = Chr(34) & str & Chr(34) : End Function
Set sh = CreateObject("WScript.Shell")
sh.Run qq("C:\path\to\pscp.exe") & " -pw PASS " & qq("D:\folders\hello.txt") _
& " unixhost:/abc_st/batchrepo/inbox", 0, True
我不确定如何将 Unix 命令放入 VBScript 文件。
我正在尝试用 VBScript 编写代码,我们可以在其中将我们的文件从 Windows 文件夹复制到 Unix 目录。
在我们的Unix目录下写入文件需要用户名和密码。
我摸索了一下,发现我们可以这样使用SCP命令来拷贝文件:
scp d:/folders/hello.txt /abc_st/batchrepo/inbox
# I am still exploring for copying files from Unix to Windows
而对于 Username/Password,我发现我们可以在 scp 命令之前使用如下所示的 sshpass 命令:
sshpass -p "your password"
# I still have to explore on this as I cant see the place for username.
有人可以建议我如何将这些命令放入 VBScript 文件中。
我会将此 VBScript 放入 HTML 文件中。 谢谢
VBScript 本身不支持 SSH,因此您需要某种 scp
实用程序来将文件从 Windows 主机复制到 Unix 主机,例如 pscp.exe
from the PuTTY suite, or the ssh package in Cygwin。
假设您使用的是 pscp.exe
,您可以 运行 客户端通过这样的 shelling out:
Set sh = CreateObject("WScript.Shell")
sh.Run "C:\path\to\pscp.exe -pw PASS D:\folders\hello.txt unixhost:/abc_st/batchrepo/inbox", 0, True
如果路径包含空格,请务必用引号引起来:
Function qq(str) : qq = Chr(34) & str & Chr(34) : End Function
Set sh = CreateObject("WScript.Shell")
sh.Run qq("C:\path\to\pscp.exe") & " -pw PASS " & qq("D:\folders\hello.txt") _
& " unixhost:/abc_st/batchrepo/inbox", 0, True