I have a program that runs from the command line. As soon as it runs, it asks for a text value and expects the return key to be pressed after that.
Is that possible to create a bash script that runs that program, wait a little bit for the prompt to appear (lets say 2 seconds) and then provide the text and the enter key?
EDIT:
I have created this script with expect but it is not working:
#!/usr/bin/expect -f
set timeout 15
set user "myusername"
set server "x.x.x.x"
spawn ssh -l $user -p AAAA $server
expect "myusername@x.x.x.x's password: "
send "the password\r"
where AAAA is the port and x.x.x.x the IP.
when I run this script it finishes almost immediately and nothing happens.
expect
? This is the sort of task it was made for – Eric Renouf Jun 11 '15 at 14:58send
command with\r
to "press enter" – Eric Renouf Jun 11 '15 at 15:27\r
on the question. The script has\r
and is not working. – Duck Jun 11 '15 at 15:44