3

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`

1 Answer 1

1

I am guessing this. I didn't try it myself. Let's see if it works.

expect_ACTIVATE=`cat << EOF`
set timeout -1
spawn  $VPNC 
expect    :            {send Pass123\r}
expect "\\$ "
send "status=`echo $?\r`"
expect eof
EOF

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.