Solved

Reading from file.Just 10 points left. Sorry!

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Virtualizing very old guest OS 4 95
Install Predefined Certificate on Ubunto 4 39
Help on running oracle SQL script in linux 3 50
ftp to port 21 4 43
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

777 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