Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Unix Horror story script question

Tags
script, shell script, shell scripting, shell scripts, unix, unix commands, unix scripting, unix scripting basics

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 11-24-2008
Question Unix Horror story script question

This text and script is borrowed from the "Unix Horror Stories" document.

It states as follows

"""""Management told us to email a security notice to every user on the our system (at that time, around 3000 users). A certain novice administrator on our system wanted to do it, so I instructed them to extract a list of users from /etc/passwd, write a simple shell loop to do the job, and throw it in the background.
Here's what they wrote (bourne shell)...

for USER in `cat user.list`;
do mail $USER <message.text &
done

Have you ever seen a load average of over 300 ??? """" END

My question is this- What is wrong with the script above? Why did it find a place in the Horror stories? It worked well when I tried it.

Maybe he intended to throw the whole script in the background and not just the Mail part. But even so it works just as well... So?
# 2  
Old 11-24-2008
RE:Unix Horror story script question

I think, it does well deserve to be placed Horror stories.
Consider the given server for with or without SMTP service role, this script tries to process 3000 mail commands in parallel to send the text to it's 3000 repective receipents.

Have you ever tried with valid 3000 e-mail IDs, you can feel the heat of CPU(sar 1 100)

P.S.: I did not tested it but theoritically affirmed.

Best Regards.
# 3  
Old 11-24-2008
Thank you for the reply. But isn't that exactly what the real admin asked the novice admin to do.

Is there a better script or solution ?
# 4  
Old 11-24-2008
Quote:
Originally Posted by scottsiddharth
Thank you for the reply. But isn't that exactly what the real admin asked the novice admin to do.

Is there a better script or solution ?
Well, Let me try to make it sequential to reduce the CPU load, but it will take no. of users*SLP_INT(default=1) seconds to execute....


#Interval between concurrent mail commands excution in seconds, minimum 1 second.
SLP_INT=1
for USER in `cat user.list`;
do; mail $USER <message.text; [ -z "${SLP_INT}" ] && sleep 1 || sleep ${SLP_INT}" ;
done
# 5  
Old 11-24-2008
Think how you would do the following task manually: send the same message to moe, larry, and curly. Now, do you really send 3 email messages? Or do you send a single email with 3 recipients?
# 6  
Old 11-25-2008
Nice and simple explanation. I assumed that the script was looping. Thank you Thunderbolt and Perderabo.
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
UNIX shell script question. arun888 Shell Programming and Scripting 3 11-12-2015 10:32 PM
UNIX script coding HW question renegade755 Homework & Coursework Questions 5 03-25-2014 01:55 PM
Unix Shell Script question GosarJunk Shell Programming and Scripting 8 02-29-2012 06:19 PM
New Unix user with shell script question using grep dtracy01 Shell Programming and Scripting 2 05-18-2011 05:17 PM
Unix Script - Changing Variable Question iamhungry Homework & Coursework Questions 1 10-25-2010 08:24 PM
Unix Script Question kencheck UNIX for Dummies Questions & Answers 2 02-15-2008 01:52 AM
The Whole Story on #! /usr/bin/ksh Perderabo Tips and Tutorials 3 04-01-2007 12:00 AM


All times are GMT -4. The time now is 11:04 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password