执行putty命令

时间:2015-08-17 11:49:18

标签: vbscript putty

我必须为进程运行一堆命令。我想把所有命令放在一个VBS文件中然后我可以单击运行它。我可以使用下面的代码调用并登录Putty,现在我必须调用这些命令。请建议如何打电话给他们。

使用Putty运行的命令:

cd /psingh69/home/                                                    
tar -cvf /psingh69/home/inbox/myfile.tar ./home/inputfiles/myfile.txt 
tar -tvf /psingh69/home/inbox/myfile.tar                              
cd /psingh69/home/destfolder/inbox/                                   
chmod 777 /psingh69/home/destfolder/inbox/myfile.tar  

VBScript代码:

Dim UserName
Dim Passwrd


UserName = InputBox("Please Enter Your UserID:")
Passwrd  = InputBox("Please Enter Your Password:")



Set shell = WScript.CreateObject("WScript.Shell")
pcmd = "C:\Users\PSingh69\Desktop\putty.exe -ssh"&" "&UserName & "@10.177.104.109 -pw" &" "&Passwrd 


Set exec = shell.Exec(pcmd)
Set pout = exec.StdOut  

我可以使用上面的脚本登录Putty。但我不知道如何调用上述命令。请建议。

1 个答案:

答案 0 :(得分:2)

大多数Putty版本允许您使用Our Products > Gifts > Food , > Gifts > Postcards , > Gifts > Liquor Our Products > Photography > Weddings , \ > Photography > Family shoots , \ > Photography > Parties Our Products > Personalisation > Labels , \ > Personalisation > Clothing, \ > Personalisation > Graphic Design 命令行开关指定“远程命令文件”。将命令添加到文本文件中,并将其作为参数传递给-m命令:

putty.exe

请注意,在VBScript字符串文字中使用时,您需要转义引号(通过加倍):

> putty.exe ... -m "c:\mycommands.sh"
相关问题