Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

Reading from file.Just 10 points left. Sorry!

I have a file of user name arranged in a single column.
I cut this column of names from a file containing details about the users and what files they had in a tmp directory.
My question is how do I read one line at a time. Each line is just the login ID of the user. I need to email each user with a notification before I delete their files from the tmp directory.
Can anyone help me? I would appreciate help with both reading the file and emailing each user.

Thanks in advance
0
pcb69
Asked:
pcb69
1 Solution
 
ozoCommented:
what one line do you want to read, and in what language are you doing the reading?
0
 
pcb69Author Commented:
Hi OZO
I want to read each line from the file.
I am using shell scripts.
I started off with a list of users and their files in the tmp directory
example of one line


-rw-r--r--   1 cn02038 cn02            1019 Mar  8  21:51 find.txt

the script I used to isolate the third column, which is the column that contains the email addresses of the users I want to send email to was:
ls -l /tmp | tr -s ' ' | cut --delimiter=' ' -f3 | sort -u > IdFile

I ended up with a column of user Id's
Example:
com30005
cno40107
jfrench
200034

How do I email each of these users with a message contained in say MesFile

Thanks again
 
0
 
samriCommented:
pcb69,

   You can try this script.

-------------------------------
#!/bin/sh

userid=`ls -l /tmp | tr -s ' ' | cut --delimiter=' ' -f3 | sort -u > IdFile`

for elements in $userid; do
   /usr/lib/sendmail $elements < /full/path/to/MesFile
# or mail $elements -s "Subject" < /full/path/to/MesFile
done
-------------------------------


Good luck,

samri
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now