With some use of expect programming, it can be easily be solved. Expect has three main commands:
- spawn
- expect
- send
Next is expect. This command will try to compare what output does the process gave us and compare it with some strings that you have provided in the script. When it matches, you can do something with it, for example give your users/password when there's a login prompt.
Last command is send, which is obvious. It sends some strings to the process and it replaces our manual input. Don't forget to end the string with "\r" so that it emulates ENTER button being pressed.
See The Geek Stuff for more examples of expect programming.
Thanks for the short introduction!
ReplyDelete