Solved

Reading from file.Just 10 points left. Sorry!

Posted on 2000-03-24
3
248 Views
Last Modified: 2010-08-05
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
Comment
Question by:pcb69
3 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2655341
what one line do you want to read, and in what language are you doing the reading?
0
 

Author Comment

by:pcb69
ID: 2655435
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
 
LVL 15

Accepted Solution

by:
samri earned 10 total points
ID: 2656463
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question