I'm trying to make this work
#!/usr/bin/expect
spawn "(psql blabla \"blabla sql;\" &> /dev/null) && (pg_restore -d xx my_file.sql &> /dev/null)"
expect "Password for user my_base: "
send "v"
But I always get:
spawn (psql blabla "blabla sql;" &> /dev/null) && (pg_restore -d xx my_file.sql &> /dev/null)
couldn't execute "(psql blabla "blabla sql;" &> /dev/null) && (pg_restore -d xx my_file.sql &> /dev/null)": no such file or directory
What am I missing?
1) don't put the
spawn
arguments in quotes, and 2) spawn doesn't understand shell syntax, you need to explicitly spawn a shellThis uses braces, which are the expect/Tcl equivalent of shell's single quotes.