简体   繁体   中英

simulate keyboard input to batch file via file and pipe on windows

the title might be slightly confusing but what I need is a method to hand over pre-configured parameters to a batchfile on windows commandline.

The batchflie executes several progams (openssl) that need interactive input. To avoid this, I wrote all necessary input parameters to a textflie and now try to do something like:

type parameters.txt | mybatchfile.bat

Unfortunately this doesn't work.

Is there a way to do this?

Passing text into stdin of interactive prompts of console programs sometimes works, but needs to be done on single line of specific program. Tested way for SSH communication in batch file:

some batch code
echo n| plink.exe -pw "somepassword" root@somehost someremotecommand
some batch code

https://the.earth.li/~sgtatham/putty/latest/w32/plink.exe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM