Reputation: 9801
I have a WindowsXP console program that offers an interactive cli mode (some cisco tool) prompting for username and password. How can I programmatically pipe those in from a .bat file?
Upvotes: 2
Views: 5700
Reputation: 11
I had the same problems, but none of the listed solutions worked. I tried different things and the following worked for me:
Command.exe "First Interactive choice" "Second one" "Third"
Upvotes: 1
Reputation: 6657
It will depend on the tool.
Hopefully the cisco tool supports command line parameters (-username=foo
etc), can read commands from a pipe (echo username | tool.exe
), or can accept an input file (tool.exe @input.txt
).
If it gets all its input from stdin, you can create a text file containing the input in the right order and pipe it to the application. For example, create a file input.txt
with this content:
myusername
mypassword
and do this so tool.exe gets its input from input.txt:
tool.exe < input.txt
But once again it depends on the tool.
Failing those easy answers, the next option is sending keystrokes to the cmd window, using jscript, vbscript or some other language. See automate a windows command line utility with a batch file - send keystrokes to std input after utility starts.
Upvotes: 5