On Sat, Sep 29, 2001 at 05:18:56PM -0700, Mike Egglestone wrote: > Hi, > > Does anyone know of such a way to email all the users > a quick message without having to send the email seperately > to each user? This is really ugly, but ... put the contents of the message you want to send in ./mymail.txt, and for i in `cat /etc/passwd` do uid=`echo $i | sed -e "s/[^:]*:[^:]*:\([^:]*\).*/\1/"` if [ $uid -ge 1000 ]; then username=`echo $i | sed -e "s/\([^:]\):.*/\1/"` echo -n "about to send mail to $username ... ..." mail -s "my subject" $username < mymail.txt echo "done" fi done 2>/dev/null This is assuming, of course, that your system follows the debian convention of making all uid's >= 1000 normal users, and all <=1000 special users (www, root, mysql, mail, etc.) Someone make me feel embarassed by posting a much more beautiful script. At the very least, replace those sed lines with awk or something. It should be much easier to say "grab the first and third field split by :'s" than that ugly regexps above. :) -ben -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Ben Hartshorne ...Discarding smoothly, as we disembark, email@example.com All thoughts that held us wiser for a moment ben.hartshorne.net Up there, alone, in the impartial dark. -M. Oliver My PGP key is at /pgp.txt. Please encrypt all communications.
Description: PGP signature