Expect Escaping with Awk
问题 I need to process the output of a single record psql query through awk before assigning it to a value in my expect script. The relevant code: spawn $env(SHELL) send "psql -U safeuser -h db test -c \"SELECT foo((SELECT id FROM table where ((table.col1 = \'$user\' AND table.col2 IS NULL) OR table.col2 = \'$user\') AND is_active LIMIT 1));\" | /bin/awk {{NR=3}} {{ print $1 }}; \r" expect "assword for user safeuser:" send "$safeuserpw\r" expect -re '*' set userpass $expect_out(0, string) When I