creating email based on an output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting creating email based on an output
# 1  
Old 02-14-2005
creating email based on an output

Hello folks. I need to create a script that looks at a certain output (list of full paths of files) and gets the owner's name (2nd position in the path, for example: /dirA/jsmith/blah1/more_blah/still_blah... etc)
Gets the jsmith and greps the related file for jsmith and send that output to jsmith, and moves to the next.

Problem: The output may contain each file listing by jsmith, and I do not want jsmith to get 100 emails (even though he deserves it, LOL).

The output is basically a monitoring list that looks at users saving files where they should not, and I would like for them to get an email automatically ...

I am sure I am making this too complicated...so any idea?
# 2  
Old 02-14-2005
something like this should get you started - not tested.
Code:
#!/bin/ksh

# file with "list of full paths of files"
inputFile='/tmp/sas.lst'

\rm -rf /tmp/mail.* 2> /dev/null

while read file
do
   user=$(echo ${file} | nawk -F'/' -v FLDuser=3 '{print $FLDuser}')
   grep "${user}" "${file}" >> "/tmp/mail.${user}.txt"
done < "${inputFile}"

for iter in /tmp/mail.*
do
   user=$(echo ${iter} | nawk -F'.' -v FLDuser=2 '{print $FLDuser}')
   mailx -s 'Subject here' "${user}" < "${iter}"
   \rm -rf "${iter}"
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting email output in single line with out space in email

I have tried below email method and i am getting every thing in single line . i have put echo to provide space, but it is not helping my code ( echo "From: $FROM" echo "To: $MAILTO" echo "CC: $CC" echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo 'Content-Type: multipart/mixed;... (6 Replies)
Discussion started by: mirwasim
6 Replies

2. UNIX for Dummies Questions & Answers

Creating a directory based on date

I want to create a directory based on date. I do not have date -d command. What I do have is: either use "date" command to get current date or DATE1=$(perl -e 'print scalar(localtime(time - 1 )), "\n";' |awk '{print $2,$3,$5}') |awk '{print $3}'can be modified to produce the desired year.... (3 Replies)
Discussion started by: newbie2010
3 Replies

3. Shell Programming and Scripting

Help with Creating file based on conditions

Can anyone please assist? I have a .txt file(File1.txt) and a property file(propertyfile.txt) . I have to read the vales from the property file and .txt file and create the output file(outputfile.txt) mentioned in the attachment. For each record in .txt file,the below mentioned values shall be... (20 Replies)
Discussion started by: vinus
20 Replies

4. Programming

Creating a bash based restricted shell

Hello. I need to write a command line interface that can be invoked either directly from the shell (command sub-command arguments), or as a shell that can process sub-commands. i want to use bash auto completion for both scenarios. example: lets say my CLI module is called 'mycli' and there... (5 Replies)
Discussion started by: noamr
5 Replies

5. Shell Programming and Scripting

creating a file name based on date

I need to automate a weekly process of piping a directory list to a csv file. Normally I do ls -l > files_04182010.csv (04182010 being the date..) Can someome show me how I would script this, so that when the script is ran it grabs the current date and formats it and allows me to use that... (8 Replies)
Discussion started by: jeffs42885
8 Replies

6. Shell Programming and Scripting

Creating folders based on number of files

I have hundreds of files numbered in consecutive number in one single folder What I would like to do is to make as many subfolders as needed (dependeing on the number of individual files) and name them Folder01, Folder02, etc. Then, move file01 to folder01, file02 to folder02 so on and so... (3 Replies)
Discussion started by: Xterra
3 Replies

7. Shell Programming and Scripting

Converting line output to column based output

Hi Guys, I am trying to convert a file which has a row based output to a column based output. My original file looks like this: 1 2 3 4 5 6 1 2 3 1 2 3 (8 Replies)
Discussion started by: npatwardhan
8 Replies

8. Shell Programming and Scripting

Shell script to email based on flat file output

Hi All, I am a newbee in unix but still have written a shell script which should trigger a mail based on certain conditions but the problem is that my file is not being read. Below is the code please advise. I do not know where is it failing. Note $ and the no followed with it is the no of... (1 Reply)
Discussion started by: apoorva
1 Replies

9. Programming

Creating email account prgramatically + java ?

Dear Friend, I am working on java application which requires that after successful registration an email account is created (say username@mydomain.com) for user. Is is possible to create e-mail account programatically ? Enviornment - CentOs, Tomcat Web server. CPanel is available, but... (0 Replies)
Discussion started by: reckless_jack
0 Replies

10. Shell Programming and Scripting

Creating a multi-recipient email script

Well, I'm fairly new to shell scripting, so please excuse my newbieness :) I was wondering if it was possible to create a shell script that retrieves a list of recipients in a list_file and sends a message out all at once? An example of a list file would look similar to this: $ cat... (2 Replies)
Discussion started by: TheSunTheSea
2 Replies
Login or Register to Ask a Question