如何从批处理文件中执行putty命令?

时间:2016-10-26 07:05:26

标签: linux windows batch-file putty

我想从本地机器打开putty并自动登录,然后在putty上执行一些命令。

我尝试了以下步骤:

创建了一个批处理文件try.bat

start D:\putty.exe -ssh ip-l root -pw password

cd "/root/something"

ls -a

scp "somefile.." root@ip "somelocation"

第一步正常。它用给定的用户名和密码打开putty。

批处理文件中存在的其他命令无效。

任何人都可以帮我解决如何在批处理文件中对putty执行这些命令的问题吗?

1 个答案:

答案 0 :(得分:1)

将最后3个命令移动到单独的文件

说D:\ scripts \ commands.txt

然后您的批处理文件可以包含

D:\putty.exe -ssh ip-l root -pw password -m "D:\scripts\commands.txt"

参考:第3.7.3.6节https://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter3.html

相关问题