Reputation: 21
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.
Upvotes: 2
Views: 11424
Reputation: 11633
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.
Upvotes: 0