Below is an shell script I have written to automate entering the password for the vpnc command. The expect works fine and vpnc activated automatically after password entered, but I need to get the exit status of the vpnc command. How can I get the exit status of vpnc?
VPNC=/bin/vpnc
expect_ACTIVATE=`cat << EOF
set timeout -1
spawn $VPNC
expect : {send Pass123\r}
expect eof
EOF`
expect -c "$expect_ACTIVATE"
I've tried doing the following to get the exit status into STATUS, but it's not quite right:
expect_ACTIVATE=`cat << EOF
set timeout -1
spawn $VPNC
expect : {send Pass123\r}
STATUS=` echo $? `
expect eof
EOF`