cancel
Showing results for 
Search instead for 
Did you mean: 

bash shell error checking

Daniel K
Occasional Advisor

bash shell error checking

hey there everyone
ive been working on this code (on unix) which reads a text file(which has student user names and marks etc), then i output real names, and total marks, averages etc
my problem is error checking tho
my arguments are
report.sh -e marks.txt
(which prints output, and count of grades and averages)
report.sh -s marks.txt
(which just prints the output)

i need error messages for the following cases
*where the data file does not exist
*an incorrect command switch is used
*a command switch is not provided
*a data file is not provided

can someone help me here, i will send u my source code,
the textfile is like this:

*i had some smaller problems, my averages and counts of grades seem to count cumulatively, how to i get it to print just the final counts, or the last average?
*i also needed to sort the output from largest to smallest total marks (without using a temp file) how can this be done?
hope im not too much bother, can someone please look at this and help within the 24 hours, im under a strict deadline and im startin to panic, thanks everyone
hope ya's can help
9 REPLIES
Daniel K
Occasional Advisor

Re: bash shell error checking

oh and here is the marks.txt file

it is based on usernames and student numbers on my unix system

but they all work, so its irrelevant to what i need
Jordan Bean
Honored Contributor

Re: bash shell error checking


Okay, give me a few days to squeeze this in and I'll even optimize it for you.

Daniel K
Occasional Advisor

Re: bash shell error checking

A few days?
:(

id hate to be a bother, but i need this done in less then 24 hours

could u just work out how to do the sorting and error checking

and if u have time the other things?

please that would be great

thanks
Daniel K
Occasional Advisor

Re: bash shell error checking

A few days?
:(

id hate to be a bother, but i need this done in less then 24 hours

could u just work out how to do the sorting and error checking

and if u have time the other things?

please that would be great

thanks
Daniel K
Occasional Advisor

Re: bash shell error checking

A few days?
:(

id hate to be a bother, but i need this done in less then 24 hours
badly......
could u just work out how to do the sorting and error checking

and if u have time the other things?

please that would be great

thanks
Daniel K
Occasional Advisor

Re: bash shell error checking

sorry my comp screwed up, i didnt realised it sent my msg 3 times....

but yeh, i have exactly 18 hours to finish this thing (damn deadlines)

r u able to do any of it by then?

i hope u can

i wont be able to thank u enough if u do
get back to me ASAP
Jordan Bean
Honored Contributor

Re: bash shell error checking


I'll try to get this to you before I go to sleep tonight. I'm currently hung-up on some bash array processing. I'd send you what I've whipped up so far, but I've lost connectivity to my work environments.

Jordan Bean
Honored Contributor

Re: bash shell error checking


This is what I have so far.

Unfortunately, the grade counters are not incrementing and I haven't even touched the averaging and sorting logic.
Jordan Bean
Honored Contributor

Re: bash shell error checking

I'm really sorry about the delay.

Revision 2 is attached. 50% rewritten.

Grade counts and overall average included. Still not sure how to sort the grades yet.

For whatever reason the grades array would not propogate to the get_grade function. So instead of trying to get this function to increment each grade element, I decided to have the parent FOR loop increment the elements using the return code of the function as the index.

I'm sure you'll have a lot of questions about what is what and how it works. So do ask.