如何将参数传递给PuTTY命令文件 [英] How to pass argument to PuTTY commands file
本文介绍了如何将参数传递给PuTTY命令文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个批处理文件,可以启动PuTTY并执行文本文件中列出的命令。我希望能够将参数传递给具有要在远程服务器上运行的命令的文本文件。
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.
这是我目前拥有的-
start C:\Users\putty.exe -load "server" -l userID -pw Password -m commands.txt
是否可以将版本号作为参数传递给命令.txt
文件?
Is there a way to pass for example a version number as an argument to the commands.txt
file?
推荐答案
您必须生成 commands.txt
动态:
set PARAMETER=parameter
echo ./myscript.sh %PARAMETER% > commands.txt
start C:\Users\putty.exe -load "server" -l userID -pw Password -m commands.txt
侧面说明:要自动执行任务,您应该考虑使用 plink.exe
而不是 putty。 exe
:
set PARAMETER=parameter
echo ./myscript.sh %PARAMETER% > commands.txt
plink.exe -load "server" -l userID -pw Password -m commands.txt
Plink甚至可以在其命令行上接受命令,这使您的任务更加轻松:
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
这篇关于如何将参数传递给PuTTY命令文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文