Reputation: 1
I want to start a console program via batch script. Starting the console program works fine. I am starting it via call xxx.exe para para
. The problem is that the console program wants an input like that after it is started.
call xxx.exe para para
please type in password:_
Is it possible to make the input of the password from the batch script.
Upvotes: 0
Views: 230
Reputation: 77657
Whether you are using batch or bash, as it seemed originally, you could try this simple piping:
echo YourPassword| program.exe parameters...
Note that if it is indeed a batch script, it is vital to make sure there's no extra space between your password and the |
, or it will be passed along with the password, as part of the password. In bash, if I'm not much mistaken, such a space would be disregarded (or maybe it would only be so if you enclosed the echoed string in quotation marks, I'm not entirely sure).
Anyway, the above doesn't always work, as some programs implement password reading in a way that disregards the input stream piped from another command.
Upvotes: 1
Reputation: 5046
You tagged your question "Windows" and "Batch" and asked about "batch" in the question. The answer to that question is: Yes, use set
like this:
set /p password=please type in password:
If you're really asking about 'bash' shell, you should re-tag your question (and change the text).
Upvotes: 0