简体   繁体   English

在 Windows 上通过文件和管道模拟键盘输入到批处理文件

[英]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.标题可能有点令人困惑,但我需要的是一种将预配置参数移交给 Windows 命令行上的批处理文件的方法。

The batchflie executes several progams (openssl) that need interactive input. batchflie 执行几个需要交互式输入的程序(openssl)。 To avoid this, I wrote all necessary input parameters to a textflie and now try to do something like:为了避免这种情况,我将所有必要的输入参数写入 textflie,现在尝试执行以下操作:

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.将文本传递到控制台程序的交互式提示的 stdin 有时会起作用,但需要在特定程序的单行上完成。 Tested way for SSH communication in batch file:在批处理文件中测试 SSH 通信的方法:

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 https://the.earth.li/~sgtatham/putty/latest/w32/plink.exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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