It seems that the above explication is inaccurate! Check out this example:
$ cat test.exp #!/usr/bin/expect set timeout 5 log_user 0 spawn bash send "ls -1 db*\r" expect { -re "^db.*$" { set bkpfile $expect_out(0,string) } } send_user "The filename is: $bkpfile\n" close $ ls -1 db* dbupgrade.log $ ./test.exp can't read "bkpfile": no such variable while executing "send_user "The filename is: $bkpfile\n"" (file "./test.exp" line 15) $
The test result is the same as when using $ expect_out (1, string) or $ expect_out (buffer). Am I missing something or is this the expected behavior?
source share