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 "[email protected]'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 forsendcommand with\rto "press enter"\ron the question. The script has\rand is not working.