使用 putty 登录时自动登录脚本运行并要求选择选项。是否可以通过另一个批处理文件/脚本提供输入? 例如:当我使用批处理文件登录说 1.1.1.10 时,它会弹出窗口,要求输入从 1 到 10 的选项号。我想自动输入该选项。
最佳答案
既然您提到了 putty,我假设您正在 Windows 工作站上工作。我不确定您是否熟悉自动热键,但是您可以使用自动热键代码片段轻松完成此操作。像这样的事情:
^+P:: ; shift-ctrl-P is the hotkey combo to activate this code
send #r ;open windows run dialog box
send \path\to\putty.exe hostname.domain.com{enter} ; stary putty and connect to server
sleep 5000 ; wait 5 seconds for connection to establish
send username{enter} ; types your username and hits enter
sleep 1000 ; wait 1 second for password prompt
send password{enter} ; types your password and hits enter
sleep 5000 ; wait 5 seconds for your autologin script to run and display menu
send 1{enter} ; type your selection and hit enter (assumes your selection is "1" here
return ; ends code snippet
您可以根据您的具体情况更改击键和等待时间。
autohotkey是一款免费软件(供个人使用),可以从http://www.autohotkey.com获取
关于linux - 提供一个脚本从另一个脚本的选项输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23535146/