Solved

Reading from file.Just 10 points left. Sorry!

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

911 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

16 Experts available now in Live!

Get 1:1 Help Now