The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Love Story iBot Cartoons for Geeks 0 11-17-2008 06:20 PM
FX: A CEP Success Story iBot Complex Event Processing RSS News 0 11-14-2008 11:00 PM
Unix Script Question kencheck UNIX for Dummies Questions & Answers 2 02-15-2008 02:52 AM
The Whole Story on #! /usr/bin/ksh Perderabo Tips and Tutorials 3 04-01-2007 01:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-24-2008
scottsiddharth scottsiddharth is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 5
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 (permalink)  
Old 11-24-2008
Thunderbolt Thunderbolt is offline
Registered User
  
 

Join Date: Sep 2006
Location: New Delhi - India
Posts: 5
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 (permalink)  
Old 11-24-2008
scottsiddharth scottsiddharth is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 5
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 (permalink)  
Old 11-24-2008
Thunderbolt Thunderbolt is offline
Registered User
  
 

Join Date: Sep 2006
Location: New Delhi - India
Posts: 5
Quote:
Originally Posted by scottsiddharth View Post
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 (permalink)  
Old 11-24-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
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 (permalink)  
Old 11-25-2008
scottsiddharth scottsiddharth is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 5
Nice and simple explanation. I assumed that the script was looping. Thank you Thunderbolt and Perderabo.
Closed Thread

Bookmarks

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0