Unix Horror story script question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix Horror story script question
# 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
Smilie Nice and simple explanation. I assumed that the script was looping. Thank you Thunderbolt and Perderabo.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX shell script question.

I need to check whether the directory is exist or not. only three letter will be passed as argument. from that it should pick the entire directory. Instead of banking and manfucuture the input will be passed as man or ban. $1 -> ban $2-> monday #!/bin/sh DIR='/sales/$1*/monday' if ;... (3 Replies)
Discussion started by: arun888
3 Replies

2. Homework & Coursework Questions

UNIX script coding HW question

i am trying to write a script code in unix that will: 1. The problem statement, all variables and given/known data: display following menu to user: (A) Add (B) Subtract (C) Multiply (D) Divide (E) Modulus (F) Exponentiation (G) Exit Then ask user for choice (A-F). After taking... (5 Replies)
Discussion started by: renegade755
5 Replies

3. Shell Programming and Scripting

Unix Shell Script question

I have the following script ========= #!/bin/sh MUTEXPREFIX="/tmp/" READMUTEX=(test globallock) # If mutexes found - exit out for m in "${READMUTEX}"; do || (echo "$0 Mutex file found - Exiting\n" ; exit 1) done; echo "After for loop\n"; exit;============= What i want... (8 Replies)
Discussion started by: GosarJunk
8 Replies

4. Shell Programming and Scripting

New Unix user with shell script question using grep

Hello, I am a new Unix user and new to shell programming. I am working on a script to go through a log file and find the text error: grep -i 'error' monplus.mplog if I find the text error in the log file I would like to echo a message to the operator staing there is an error I am currently... (2 Replies)
Discussion started by: dtracy01
2 Replies

5. Homework & Coursework Questions

Unix Script - Changing Variable Question

This is a problem with basic Unix scripting. Thanks for looking! 1. The problem statement, all variables and given/known data: Make a script that will compare 2 given directories and output those filenames that are in Directory 1 and not 2 2. Relevant commands, code, scripts, algorithms:... (1 Reply)
Discussion started by: iamhungry
1 Replies

6. UNIX for Dummies Questions & Answers

Unix Script Question

Hi to all in forum and I hope someone will be able to help. It is likely that over the next couple of months I have to get a hands on knowledge of Unix due to incoming work in company and I hope to be able to get some knowledge from the general Unix community. In the meantime I have one... (2 Replies)
Discussion started by: kencheck
2 Replies
Login or Register to Ask a Question