#!/bin/bash # Thu Feb 19 00:05:22 EST 2004 # NAME: popstat1 # Copyright 2004, Chris F.A. Johnson # Released under the terms of the GNU General Public License pop3stat() { exec 3<>/dev/tcp/$pop/110 read ok num x <&3 popcmd user $user && popcmd pass $pass && popcmd stat } popcmd() { local IFS=${IFS}$'\r' cmd=$* echo $cmd >&3 read ok num x <&3 [ "$ok" = "+OK" ] } main() { ## set these variables to appropriate values pop=pop.your-isp.com user=$USER pass=password pop3stat || { echo "popcmd \"$cmd\" failed"; exit 5; } [ $num -eq 1 ] && _PL= || _PL=s echo "You have $num message$_PL" popcmd quit } main