-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I automate inputs to interactive programs? #143
Comments
If the program reads from standard input, then running it via script.Echo("hello").Exec("cat").Stdout()
// Output:
// hello |
Note that this probably won't work for programs which ignore their process's configured standard input stream, and read directly from the terminal device, as some do to avoid echoing characters (when typing passwords, for example). If you have a use case like that, I'd be interested to hear about it. |
Hello, script.Echo("Password").Exec("sudo apt-get update").Tee().Wait() Doesn't seem to work for sudo password. Maybe this is a good thing, however, this operation doesn't work either: script.Echo("Y").Exec("sudo apt-get remove python3").Tee().Wait() Is this an error on my part or an example of a program reading directly from the terminal device? |
I think the latter; try |
Every so often, I need to automate tasks that need to provide answers to interactive programs
For instance, to simulate user's sessions or just because the program does not provide
a non-interactive interface.
Normally, I use "expect" for that (ex: https://phoenixnap.com/kb/linux-expect)
How can the same feature be implemented with go script?
Thanks
The text was updated successfully, but these errors were encountered: