How to pass user input automatically using plink.exe

守給你的承諾、 提交于 2019-12-08 11:06:41

问题


I need to login to an SSH session using password, and then execute the user input values for a particular account.

For example:

PLINK.EXE -ssh ***** -l ***** -pw *****

I am able to login, now what I need to do is enter below values:

  • Please select account to logon: "U"
  • Press RETURN to continue or OFF to cancel session - "RETURN"

There are similarly this kind of user inputs needed. Is there a way I store the "*" values in a text file and load them using Plink.

I tried:

PLINK.EXE -ssh ***** -l ***** -pw ***** -m C:\input.txt

This does not seems to be working.

Expectation: Passing all the user input i.e. "U", "RETURN" .... using Plink or any other PuTTY tool.

Appreciate your help!


回答1:


The -m switch is used to execute commands in shell. You cannot use it to provide inputs for the executed commands.

But as Plink is a console application, you can use an input redirection to provide input:

plink.exe -ssh ... -l ... -pw ... < C:\input.txt


来源:https://stackoverflow.com/questions/34477728/how-to-pass-user-input-automatically-using-plink-exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!