LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-14-2014, 03:20 PM   #1
Joejr4u
LQ Newbie
 
Registered: Nov 2006
Location: Dallas, TX
Distribution: SUSE 11, RHEL 6, Ubuntu
Posts: 9

Rep: Reputation: Disabled
Smile Help Me Please!! Script to email users from a list of directories they own


Hello,

I am sort of a newbie in scripting. I would like some tips and maybe a starting template for a script I can use in sending emails (read from a file) a message to multiple users based off another list I generated. This list has directories owned by the users and their usernames. What would be the best conditional statements to use?

Thanks
 
Old 03-14-2014, 03:38 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,646

Rep: Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969
Quote:
Originally Posted by Joejr4u View Post
Hello,
I am sort of a newbie in scripting. I would like some tips and maybe a starting template for a script I can use in sending emails (read from a file) a message to multiple users based off another list I generated. This list has directories owned by the users and their usernames. What would be the best conditional statements to use?

Thanks
The man pages on ls contain options you should check out. A simplistic way of doing it would be to do shovel an "ls -l" through awk to get the owner field and the file name, then operate on it.

Post what you've written/tried and tell us where you're stuck. Otherwise, there are MANY script templates/tutorials/sample code you can find easily. My posting signature has one, and the bash scripting tutorials on TLDP are excellent.
 
Old 03-14-2014, 05:38 PM   #3
Joejr4u
LQ Newbie
 
Registered: Nov 2006
Location: Dallas, TX
Distribution: SUSE 11, RHEL 6, Ubuntu
Posts: 9

Original Poster
Rep: Reputation: Disabled
#!/bin/bash

FILE=/path/to/file/listing # contains information of directory paths and server it resides. there are 3 different servers
TMPFILE=TEMPF # contains listing of users with most files
SCRIPT=/path/to/script
MAIL=/path/to/mail/message
#TMPDIR=TEMPD

for i in `awk '{print $3}' FILE` # column3 shows directory names

do

# script creates a listing of users with most directories (from most to least) and then output for each iteration into a temporary listing
echo $SCRIPT $i > $TEMPF

# The top two users will be sent a mail. TEMPF will be appended to body of MAIL
done

# next statements not complete
while "${TMPFILE}"/*; do
mailx -s "TEST EMAIL" -r test@mail.com "${MAIL##*/}" <"${}"
rm -r "${TMPFILE}"
done


I will appreciate your help in piecing together what I'm trying to achieve. I understand the logic of what I am trying to do but cannot translate it properly into scripting code.

Any suggestions will be helpful.

Thanks for the inputs,

Silverhawk
 
Old 03-16-2014, 01:55 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,868
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Code:
while "${TMPFILE}"/*; do
While doesn't work this way. Try help for in bash.

Please read this topic: What information to include in a post and how to use code tags
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to delete a list of Directories quanvu07 Linux - Newbie 8 10-25-2010 08:26 PM
Obtaining list of files in all users directories aarontwc Programming 4 12-21-2008 08:08 PM
Looking for a script that would list ALL users cronjobs stefaandk *BSD 3 09-22-2008 11:25 AM
print list of email addresses from .dbx directories esteeven Linux - General 1 05-04-2007 02:51 PM
Script to create multiple directories under users homes shawnbishop Linux - Software 4 03-30-2006 08:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration