Solved

Reading from file.Just 10 points left. Sorry!

Posted on 2000-03-24
3
233 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now