'Open PuTTY and run shell script on server
I want to open Putty from local machine, automatically login to the server, and run shell script on the same session of putty using Excel VBA Script. The code below works fine to open putty.
Sub open_putty()
Dim UserName 'assign user name
Dim Passwrd 'assign password
Dim TaskID As Long
pc1 = "C:\Users\Desktop\putty.exe -ssh " & UserName & "@servernamee -pw " & Passwrd
TaskID = Shell(pc1, 1)
End Sub
However, I'm not able to run the shell script test.sh on the same session. The script is in the default location after login. How can I run the shell script on the server using Excel VBA.
Solution 1:[1]
I'm pretty sure you need to use the -m parameter.
Like this:
pc1 = "C:\Users\Desktop\putty.exe -ssh " & UserName & "@servernamee -pw " & Passwrd & " -m c:\temp\test.sh"
TaskID = Shell(pc1, 1)
You might also consider use plink.exe, which is the command line connection utility.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Marc |
