In my bash script I am installing my application. I need to respond to three questions that need the following 3 responses as part of the application being installed.
I have provided an example below of the first entry I am trying to make in my bash script.
Any help determining if I am using correct context or there is a better one.
My script calls all other actions except this one.
#!/bin/bash
.....
sleep3
send "c\r"
expect "Continue [c,Enter], Exit [e]"
here's a trivial example using expect to mimic you scenario - and a stub python 'application' that 'expects' 3 responses.
cat jdubs.sh
#!/usr/bin/expect
set responses {"c" "y" ""}
spawn ./app.py
foreach resp $responses {
expect -re ".*"
send "$resp\r"
}
expect eof
cat app.py
#! /usr/bin/env python
import sys
import datetime
r1=input('prompt1:')
r2=input('prompt2:')
r3=input('prompt3:')
print(f'\n\n{datetime.datetime.now()}: installed {sys.argv[0]}, with responses:{r1} :{r2} :{r3}')
#
# test
#
./jdubs.sh
spawn ./app.py
c
y
prompt1:prompt2:prompt3:
2025-05-01 09:33:51.039400: installed ./app.py, with responses:c :y :