#!/usr/local/bin/expect -- # proc select_msgs {} { if {! [file exists msglist]} { return 1 } if {[catch {exec grep -q ^\[0-9]\[0-9]\[0-9] msglist} errno]} { send_user "No messages in list.\n"; return 1 } catch {system vi msglist} errno if {[catch {system awk 'BEGIN \{printf \"r \"\; n = 0\} \ /^\\t/\{printf \"%d \", \$1\; n++\} \ END \{printf \"\\n\"\; if (n) exit 0\; else exit 1\}' \ msglist > readcmd } errno ]} { return 1 } else { return 0 } } if {[select_msgs] == 0} { send_user "Yes!\n" } .