Necessary Info: I'm trying to use expect to automate a password involving a command with PostgreSQL in a BASH script. I've tried mimicking several examples I found here on StackOverflow.com and also other resources on the internet with no success.
Issue: I'm still getting prompted for input.
Code:
Extra Info: password is a global variable not shown in this snippet
database_work(){
sudo -u postgres createdb tinyows
sudo python /$1/database.py
expect <<- DONE
spawn sudo -u postgres psql -U postgres -d tinyows < `pg_config --sharedir`/contrib/postgis-2.1/postgis.sql
expect "*?assword:*"
send -- "$password\r"
send -- "\r"
expect eof
DONE
expect <<- DONE
spawn sudo -u postgres psql -U postgres -d tinyows < `pg_config --sharedir`/contrib/postgis-2.1/spatial_ref_sys.sql
expect "*?assword:*"
send -- "$password\r"
send -- "\r"
expect eof
DONE
}
Ending Note: I appreciate any help and advice anyone gives, thank you.