LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux command mail question very easy for you not for me ! (https://www.linuxquestions.org/questions/linux-newbie-8/linux-command-mail-question-very-easy-for-you-not-for-me-486791/)

zonemikel 09-25-2006 09:13 AM

Linux command mail question very easy for you not for me !
 
Ok im kinda confused as to how linux mail from the command works, it seems to have its own built in mailing thing i can send mail using echo "message" | mail -s "subject" somone@somedomain.com so i thought i would make that in a batch script and whiped something out really quick it basically said

Code:

i=0
while [$i -lt 9999]
do
echo "message" | mail -s "subject" $i@somedomain.com
echo "sending message to $i@somedomain.com"
clear
let $i=$i+1
done

Well why in the hell would i do that, i dont know but hindsight is 20/20 right? Anyway my screen filled with text when i ran the script sending out emails at blazing fast speeds (or so i thought) after it got to around a thousand it stopped and i ctrl-c to get out of it. Then i couldnt send mail to anyone i tried using it from the command prompt and every way i could. So i left it alone and went to bed, the next morning i woke up and i still couldnt send mail so i restarted the box. As soon as i logged in beep, beep, beep ... new mail with the subject: WARNING could not send message for the past 4 hours its been about 30min and they are still coming in .. a little slower now but they are still coming. I would imagine these are returned mail that couldnt be sent?
My question is what the hell happened ? is there a limit ? I now have a sleep command before the done part of my script and im getting ready to run it again soon. any ideas ?

**UPDATE** i had let $i=$i+1 in my code but i was writing it here from memory so i didnt add that part, but now i added it to the above code. It did incrament when i ran it but i think it like ran too fast and didnt allow the process to complete before starting another mail instance ? but why do i get all this return mail to root ?

jonlake 09-25-2006 11:59 AM

First hing that comes to mind
 
Look at your script. When is $i ever going to not be less than 9999? Never. You aren't incrementing your variable at all. You may want to put his after the echo commands, or the clear command.

Code:

$i++
This will increment the variable by one each time your script runs).


All times are GMT -5. The time now is 05:26 PM.