set timeout 60 spawn socat unix-connect:vm/console - send "\r\n" expect "#" set FINISHED 0 set EXIT "1" while { $FINISHED < 10 } { send "ip address show dev ppp0 | grep ppp0\r\n" expect { "192.168.100.1" { set FINISHED 20; set EXIT 0; } "can't find device" { send_user "waiting ..." ; send "\r\n"; sleep 3 } "DOWN" { send_user "waiting ..." ; send "\r\n"; sleep 3 } } set FINISHED [ expr $FINISHED + 1 ] } exit $EXIT