Reputation: 1496
I have to run a bunch of commands for a process. I am able to call and login to Putty using the command below and want to be able to execute tar and other things.
I call putty using the following
"C:\Users\PSingh69\Desktop\putty.exe -ssh"&" "&UserName & "@10.177.104.109 -pw" &" "&Passwrd
Commands to send to the remote host using 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
I am able to login to Putty using above command, but I am not sure of how to make the remote host run the above lines.
Upvotes: 1
Views: 13816
Reputation: 16311
Most versions of Putty allow you to specify a "remote command file" using the -m
command-line switch. Add your commands to a text file and pass it as a parameter to your putty.exe
command:
> putty.exe ... -m "c:\mycommands.sh"
Note that you'll need to escape your quotes (by doubling them) when used in a VBScript string literal:
pcmd = "putty.exe -m ""c:\mycommands.sh"""
Upvotes: 1