Answer the question
In order to leave comments, you need to log in
Is it possible to register in a bash script interactive input of a login-password for GitHub and a MySQL command call?
I need to automate
1. Dump a table from MySQL to a file (ex.
mysql> SELECT * FROM passwd INTO OUTFILE '/tmp/passwd.txt'
) GitHub asks for a username/password - can it be entered interactively with Bash?
Answer the question
In order to leave comments, you need to log in
Taken from www.tech-notes.net/use-expect-in-bash
the script takes a username and password as arguments, then connects with them to the server 192.168.1.10 and executes cat /etc/issue
#!/usr/bin there /expect
log_file expect_log
set login [lindex $argv 0]
set pw [lindex $argv 1]
spawn ssh [email protected]
expect "[email protected]\'s password:"
send "$pw\r"
expect "[email protected]"
send "cat /etc/issue\r" You
can execute it like this:
expect -f script.exp user password
The second option is to run everything directly in bash:
expect -c 'spawn ssh [email protected]; expect `Password:` {send - `password\r`};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question