The UNIX and Linux Forums  

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
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 12:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 12:06 AM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 07:15 AM
returning to the parent shell after invoking a script within a script gurukottur Shell Programming and Scripting 5 09-26-2006 04:05 AM
return valuse from child script to parent script borncrazy Shell Programming and Scripting 1 08-20-2004 12:39 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-29-2008
Registered User
 

Join Date: Apr 2008
Posts: 6
script

I'm trying to learn unix and was going through some problems when I ran into this questiona about creating a script that will caclulae the suam and average of the scores for the assignments and quizzes after it drops the worst one. this tool will manage the data with each own weight and generate a final grade in the letter format. Also provide the option to send the grade report to user by email. an if then else fi command is expected in the script, same as case in esac and for while loop. Unix `trap` function shall be included to demo how it uses it.
Reply With Quote
Forum Sponsor
  #2  
Old 04-29-2008
Registered User
 

Join Date: Feb 2008
Location: New Zealand
Posts: 44
And what's ur question?
Reply With Quote
  #3  
Old 04-29-2008
Registered User
 

Join Date: Apr 2008
Posts: 6
stuck

Im not to sure where I'm even supposed to begin with this program. I am a first time user. trying to try to prorams that I'm trying to understand
Reply With Quote
  #4  
Old 04-29-2008
matt.d's Avatar
Registered User
 

Join Date: Feb 2008
Location: /dev/null
Posts: 62
Sounds like a homework question...

Take the program in pieces. Start simple
Reply With Quote
  #5  
Old 04-29-2008
Registered User
 

Join Date: Apr 2008
Posts: 6
I'm going through a unix book that I bought. But I wanted to know if it was possible to see an example to see it I understand it but I have no clue to where to begin
Reply With Quote
  #6  
Old 04-29-2008
Registered User
 

Join Date: Feb 2008
Location: New Zealand
Posts: 44
The best thing to start a script is to tell the shell in which shell the script has to run

#!/usr/bin/bash

and then...
Reply With Quote
  #7  
Old 04-29-2008
Registered User
 

Join Date: Apr 2008
Posts: 6
i have that so far this is what i have
#!/usr/bin/ksh
#
#export PATH=/bin:/usr/bin
#
#shell variables
PROG=`basename $0`
#
#OutFile=/tmp/$LOGNAME.$PROG
#
#echo "Hi $LOGNAME:\n\tPlease enter scores of assignments (seperate by 'space'): \c"
read input
echo
#
Counter=0
Total=0
Worst=999
cp/dev/null $OutFile
#
for score in $Input
do
#
case "$score" in
[0-9]|[1-9][0-9]|100)
Counter=`expr $Counter +1`
[$score -it$worst] && Worst=$score
Total=`expr $Total + $score`
echo "\tHw-${Counter}: ${score}, Sum: ${Total}, Worst One: $Worst" | tee-a $OutFile
;;
[0-9]|[1-9][0-9]|100)
echo "\tYou enter <$score> which is greater than 100 ==> no! no!!" >&2
exit 10
;;
*)
echo "\tYou enter <$score> which is not a positve number">&2
exit 20
;;
esac
done
#
echo"
$Counter Assignments Total: ${Total}, Worst: $Worst" | tee-a $OutFile
Conter=`expr $Counter -1`
Total=`expr $Total - $Worst`
Average=`expr $Total/$Counter`
echo"
Average is $Average" | tee-a $OutFile
#
echo "Enter the email id to receive tis report: \c"
read Rcptld
if [-n "Rcptld"]; then
mailx-s "CMP-322 Reportcard" $Rcptld <$OutFile
fi
#
exit 0




but Im still missing the if-then-else-fi command, a case-in-esac, and for/while loop, a trap function, and also a function to check input. And that's what I don't know how to do.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




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


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

Content Relevant URLs by vBSEO 3.2.0