|
Home > Archive > Unix Shell > May 2007 > awk and uniq
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| merrittr 2007-05-29, 1:19 am |
| I am trying to get the script below to mail out 1 email to each person
logged in however:
finger gives
bash-3.1$ finger
Login Name Tty Idle Login Time Office
Office Phone
rwm132 Robert Wesley Merritt pts/0 May 28 18:51
(reif.usask.ca)
rwm132 Robert Wesley Merritt *pts/1 51d May 24 18:53
(reif.usask.ca)
rwm132 Robert Wesley Merritt *pts/5 51d May 25 08:28
(reif.usask.ca)
rwm132 Robert Wesley Merritt *pts/2 51d May 25 11:00
(reif.usask.ca)
so I only want to send onee email, any ideas how i do that
#!/bin/sh
allnsid=""
finger | awk '{print $1} {print $2} {print $4}'|while read nsid
do
read fn
read ln
allnsid="$allnsid $nsid"
echo "hello $fn $ln" >> $nsid.txt
echo "please" >> $nsid.txt
echo "lof off " >> $nsid.txt
echo "the" >> $nsid.txt
echo "machine" >> $nsid.txt
#mail -s logoff $nsid@mail.usask.ca < $nsid.txt
case $allnsid in
*$nsid*)
echo "mailing to $nsid $fn $ln"
;;
esac
echo $allnsid
done
| |
| Harry331 2007-05-29, 1:19 am |
| merrittr wrote...
>
>I am trying to get the script below to mail out 1 email to each person
>logged in however:
man wall
Wall displays the contents of file or, by default, its standard input, on
the terminals of all currently logged in users.
| |
| Barry Margolin 2007-05-30, 7:17 am |
| In article <1180405184.971791.263810@o11g2000prd.googlegroups.com>,
merrittr <merrittr@gmail.com> wrote:
> I am trying to get the script below to mail out 1 email to each person
> logged in however:
>
> finger gives
> bash-3.1$ finger
> Login Name Tty Idle Login Time Office
> Office Phone
> rwm132 Robert Wesley Merritt pts/0 May 28 18:51
> (reif.usask.ca)
> rwm132 Robert Wesley Merritt *pts/1 51d May 24 18:53
> (reif.usask.ca)
> rwm132 Robert Wesley Merritt *pts/5 51d May 25 08:28
> (reif.usask.ca)
> rwm132 Robert Wesley Merritt *pts/2 51d May 25 11:00
> (reif.usask.ca)
> so I only want to send onee email, any ideas how i do that
>
>
>
>
> #!/bin/sh
>
> allnsid=""
> finger | awk '{print $1} {print $2} {print $4}'|while read nsid
> do
> read fn
> read ln
> allnsid="$allnsid $nsid"
> echo "hello $fn $ln" >> $nsid.txt
> echo "please" >> $nsid.txt
> echo "lof off " >> $nsid.txt
> echo "the" >> $nsid.txt
> echo "machine" >> $nsid.txt
> #mail -s logoff $nsid@mail.usask.ca < $nsid.txt
>
> case $allnsid in
> *$nsid*)
> echo "mailing to $nsid $fn $ln"
> ;;
> esac
>
> echo $allnsid
> done
finger | awk '{fullname[$1]=$2 " " $4 }
END {for (id in fullname) print id, fullname[id]}' | \
while read nsid fn ln
do
mail -s logoff $nsid@mail.usask.ca <<EOF
hello $fn $ln
please
log off
the
machine
EOF
done
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
|
|
|
|
|