The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Standard UNIX functions Zipi High Level Programming 2 02-23-2009 12:41 PM
Similar functions in unix dayakarr High Level Programming 1 02-14-2009 10:44 AM
Excuting UNIX Functions under several username and host samvino Shell Programming and Scripting 1 07-01-2008 10:44 AM
newbie to unix programming in C, needed a few simple prgs on these functions! wrapster High Level Programming 1 06-22-2008 01:12 PM
Use of functions amitrajvarma Shell Programming and Scripting 1 11-23-2007 06:52 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-24-2009
Usha Shastri Usha Shastri is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 13
unix functions

Hi All,

i have two functions in my script.

Code:
question()
{
num=`ps -e | grep ps | awk -F" " '{print $1}'` 
qno=`expr $num % 10`
grade=grade1 
cat grade1/$qno
answer ${grade} ${qno} 
}
answer()
{
grade=$1
qno=$2
ansno=`wc -l $grade/ans/$qno | cut -d' ' -f1`
j=0 
while [ $j -lt $ansno ]
do
echo select your answer 
read ans[$j]

echo "do you want to select one more answer?"
read ch
if [ $ch != y ]
then
break;
fi
j=`expr $j + 1`
done
k=0 
exec < $grade/ans/$qno
while read line
do
echo line=$line 
while [ $k -lt $ansno ]
do
if [ ${ans[$k]} = $line ]
then
echo "equal"
else
echo "not equal"
fi
k=`expr $k + 1`
done 
done 
}
i am calling question function 3 times in a loop. for the 1st times it works fine, 2nd and 3rd time this will not take input for ans[$j]
can you please help?
thanks

Last edited by Yogesh Sawant; 03-25-2009 at 02:28 AM.. Reason: added code tags
 

Bookmarks

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 10:03 PM.


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