This is a discussion on script for mailing to user the o/p of the script within the Shell scripting forums, part of the Development/Scripting category; I want to write a script that mails the user the o/p of a script. How can we do this. ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
I want to write a script that mails the user the o/p of a script. How can we do this.
suppose, the code is something like this: Code:
#!/bin/bash
#lets name the file getusrlog
ulog=~/userslog
oulog=~/olduserlog
mv $ulog $oulog
cat /dev/null > $ulog
for i in $(who |cut -f1 -d" "|grep -vE "(^-|this|the)" )
do
echo "These are the users logged on : $i `date '+on %d-%m-%y at %H-%M-%S'`">>$ulog
done
if [ $? = 0 ]
then
echo "Program $0 completed successfully" >> $ulog
else
echo "Program $0 failed" >> $ulog
fi
mail _______________# mail the user the contents of $ulog( i don't know how to do it)
Thanks rc |
| Sponsored Links | ||
|
|
|
||||
|
Simple use mail command
mail -s "SUBJECT" myemail@somewhere.com < /tmp/file.txt So to send an email from your script( add to end of your above script): Code:
EMAILID=”me@yahoo.com” mail -s "Output of $0 script“ “$EMAILID” <$ULOG sending an mail with attachment using mutt http://www.cyberciti.biz/nixcraft/vi...ttachment.html |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| calling a script within a script | Predatorian | Shell scripting | 2 | 04-07-2008 02:59 AM |
| Alphabetical file name and list logged in user script | oronno | Shell scripting | 5 | 08-22-2007 01:10 PM |
| How can i create script for deleting user? | Paul | Shell scripting | 1 | 08-02-2007 11:20 PM |
| Shell script or code for deleting a user | narasimha.reddygnv | Shell scripting | 5 | 03-19-2007 11:07 AM |
| script who will control user processess | darknet | Shell scripting | 2 | 01-02-2007 11:40 PM |