The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing global variable to a function which is called by another function sars Shell Programming and Scripting 4 06-30-2008 08:39 AM
Help with the 2 for loops vadharah Shell Programming and Scripting 1 03-04-2008 12:26 PM
two loops big123456 UNIX for Dummies Questions & Answers 2 10-11-2005 12:08 AM
Loops mariner UNIX for Advanced & Expert Users 2 07-01-2004 04:50 AM
no more loops tony3101 Shell Programming and Scripting 5 06-09-2004 11:01 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-13-2004
Registered User
 

Join Date: Nov 2003
Location: Grimsby
Posts: 17
loops within a function

I have a function where i am imputting data to the function. Within the function is a while loop reading the data put into the function. I want to put a FOR loop within the while loop but it keeps stopping the while loop on the first run. Could anyone help please.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-13-2004
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
Please post the code that you have. Also, what shell and OS are you using? Example

Code:
myFunction () {
while true
do
   for iteration in $list
   do
      echo $iteration
   done
done
}
Reply With Quote
  #3 (permalink)  
Old 10-13-2004
Registered User
 

Join Date: Nov 2003
Location: Grimsby
Posts: 17
Operatoring system AIX 5.1

example code,


function error_routine
{
while read user_id day_no month time error_file
do
USER=`grep ${user_id} $passwordfile | sed 's/:/ /g' | awk '{ print $5,$6 }
'`

echo "$USER created error file $error_file in $testdir on $d
ay_no $month at $time"

for RECIPIENT in ${MAIL_ADDRESS}
do
MAIL_SUBJECT="$USER has generated an error fil
e: $error_file in $testdir on $day_no $month at $time"
pine -I^X,y -subject "${MAIL_SUBJECT}" ${RECIPIENT}
EXIT_CODE=$?
if [ ${EXIT_CODE} -ne 0 ]
then
EXIT_CODE=1
echo "There was a problem emailing the error file: $erro
f_file in $testdir generated by $USER on $day_no $month at $time to
${RECIPIENT}"
fi
done


done
}

error_routine<$OUTPUT
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:24 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0