0

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?

2
  • 2
    It strongly depends on the command you are using. Perhaps it doesn't accept input from stdin or you have to add an output delay between echo ID and echo PASSWORD, or it fails, because the way you try it always appends a space after ID and PASSWORD and your command doesn't accept ID/Passwords with spaces ... Commented Jun 27, 2019 at 12:17
  • Actually, I'm trying to install some python modules with pip but there are securities to access a host which asks the user id and the password. But there are too many modules so I want to automate those steps. Commented Jun 27, 2019 at 14:56

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.