Re: Script for mailing /etc/passwd information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The code given below will fetch the all the users and its corresponding
shell info and copies in a file. Then sends this file to the desired mailing
address.

#!/bin/bash
filename=/tmp/passwdinfo.txt
while read line
do
 username=`echo $line | cut -d":" -f1`
 shellname=`echo $line | cut -d":" -f7`
 echo "User: $username" >>$filename
 echo -e "Shell: $shellname\n" >>$filename
done</etc/passwd
echo "Mailing information"
cat $filename | mail -s "SUBJECT" mail@xxxxxxxx
# For sending file as attachment, uncomment the below line and comment the
above.
mutt -a $filename -s "SUBJECT" mail@xxxxxxxx
[ $? = 0 ] && echo "mail sent successfully."; rm -vf $filename || echo
"Error while sending mail."

Hope this helps.

Regards,

Kurian Thayil.

On Mon, Jun 1, 2009 at 7:03 PM, Hike <mh1272@xxxxxxxxx> wrote:

> This a good time to learn.
> (Apart from the security nightmare you may be creating.)
>
> awk, cut, are to use inside a scripy
> perl would be good, too
>
>
> On Jun 1, 2009, at 9:10 AM, a bv <vbavbalist@xxxxxxxxx> wrote:
>
> Hi list,
>>
>> I need a script which will get the users and their shell from
>> /etc/passwd file and mail it to the company mail account which i use
>> on Lotus Notes. Im not yet a scripting guy so i wanted to ask to you.
>>
>> Regards
>>
>> --
>> redhat-list mailing list
>> unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
>> https://www.redhat.com/mailman/listinfo/redhat-list
>>
>
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>
-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux