简体   繁体   中英

How to use multiple input using pipe in a batch file?

I'd like to use 2 inputs, ( ID and PASSWORD ), in a command.

The command I want to use asks me for an ID and a PASSWORD but when I use the command:

(echo ID && echo PASSWORD) | command

The ID is executed but not the PASSWORD (it waits for a password to be entered) and I don't know why...

I spent lot of time trying to find an answer but I failed... Is there anybody who can help me?

What you are attempting to do will rarely work, as many commands only accept a password as active input from stdin.

For instance the telnet command can not be scripted by design.

The FTP command requires specifying an external script file as an argument.

A few things to check:

Does the command offer you a way to enter the un/pw as arguments?

Look into the command's documentation, and try command /? to see what it accepts.

Also, some commands that do accept piped input will do so best when the input is stored in a text file and sent to it via redirection

ie <"C:\\FilePath\\FileName.txt" Command

YMMV, good luck

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