I have a batch file that starts PuTTY and executes commands listed in a text file. I want to be able to pass in parameters to the text file that has my commands to be run on the remote server.
This is what I currently have -
start C:\Users\putty.exe -load "server" -l userID -pw Password -m commands.txt
Is there a way to pass for example a version number as an argument to the commands.txt
file?
You have to generate the commands.txt
on the fly:
set PARAMETER=parameter
echo ./myscript.sh %PARAMETER% > commands.txt
start C:\Users\putty.exe -load "server" -l userID -pw Password -m commands.txt
Side note: To automate tasks, you should consider using plink.exe
instead of putty.exe
:
set PARAMETER=parameter
echo ./myscript.sh %PARAMETER% > commands.txt
plink.exe -load "server" -l userID -pw Password -m commands.txt
Plink can even accept the command on its command-line, what makes your task even easier:
plink.exe -load "server" -l userID -pw Password ./myscript.sh parameter