HELP PLEASE!! school assignment due in two hours!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting HELP PLEASE!! school assignment due in two hours!!
# 1  
Old 05-08-2008
HELP PLEASE!! school assignment due in two hours!!

The assignment is worth 100 points.

Write a shell script that implements a report writer. The script file should be called "report" and should be invocable as

report

from the command line. In your script you may use common Unix commands: make sure that your script runs fine on lx.cs.niu.edu.

The script uses 3 data files -- called "products", "sales", "associates" -- as described below:

products: has the following fields, the field separator is ":"

* product id: an integer number
* description: alphanumeric text
* price: floating point number, with 2 significant digits

sales: has the following fields, the field separator is ","

* product id: an integer number
* quantity: an integer number
* date: in the form of dd:mm:yyyy
* associate id: an integer number

associates: has the following fields, the field separator is "/"

* associate id: an integer number
* name: alphanumeric text
* salary: an integer number
* position: alphanumeric text

(click here to see examples of these files.)

The script should compute the sale amounts per associate for the year 2008 and print them in a list ranked according to the sales amount. Your script should invoke Unix commands on the above files to produce a report on standard output. Here is an example of the script invocation using the data provided in the example files above:

$ ./report
Marine Parts R US
2008 Sales Associates Ranking

Name Position Sales Amount
========================================
Fast Buck Stock Boy 2408.87
George Bush President 1059.67
Susan Worker Manager 139.76
John Doe Clerk 134.01
Hillary Clinton Candidate 31.00
$


Make sure that your script repors any error, such as problems with the input files, and that all temporary files are removed once the script ends.

I HAVE NO IDEA HOW TO GET THIS TO WORK, I HAVE GOTTEN SOME CODE DOWN BUT IT GETS STUCK ON ONE PART. HERES MY CODE, SOMEONE PLEASE HELP ME!!!!

#! /bin/bash
awk '/2007/ {print $0}' sales > /tmp/newSales.$$
#wc -l /tmp/newSales.$$ | cut -c1-2 > $LINES
LINES=`wc -l /tmp/newSales.$$ | cut -c1-2`
echo lines in file $LINES
COUNTER=21
while [ $COUNTER -le 26 ]
do
COUNT=1
while [ $COUNT -lt $LINES ]
do
awk '$4 == $COUNTER {print $0}' /tmp/newSales.$$ >> /tmp/sales.$COUNTER.$$
let COUNT=$COUNT+1
done
echo "SALES FOR ASSOCIATE $COUNTER"
cat /tmp/sales.$COUNTER.$$
let COUNTER=$COUNTER+1
done

#Below removes all created files
rm /tmp/newSales.$$
i=21
while [ $i -le 26 ]
do
# rm /tmp/sales.$COUNTER.$$
let i=$i+1
done


I THINK THE PROBLEM IS IN.....

awk '$4 == $COUNTER {print $0}' /tmp/newSales.$$ >> /tmp/sales.$COUNTER.$$
# 2  
Old 05-08-2008
No homework questions here, read the rules.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

2. Shell Programming and Scripting

School assignment

Hi, I have assignment from school. Please help me write the script for following example Using "eval", write a program called "recho" that prints its arguments in reverse order. For example, $recho one two three should produce three two one (1 Reply)
Discussion started by: sdp5628
1 Replies

3. OS X (Apple)

school unix

i have really no administrative privileges at my school how can i add my self to passwd and create a root account? (6 Replies)
Discussion started by: shanepowell
6 Replies

4. AIX

Need help with OLD SCHOOL AIX

Whats up ppl... I'm at a loss here.. Getting help with old versions of AIX is quite stressful lol... Anyways.. My situation is that I (my company) has an old Powerserver 220 running AIX 3.2.5. The server is about to crap out, and we need to move the system over to a newer box. I've... (3 Replies)
Discussion started by: NOTORIOUS VR
3 Replies

5. IP Networking

School Blocking

I'm in highschool. They blocked my favorite site. How do I disable websense without getting caught on that particular webpage? Is it even possible? *twitch* I would also like to get as much UNIX for beginners information, so if someone might point me in the right direction so I don't have to read... (1 Reply)
Discussion started by: Satine
1 Replies
Login or Register to Ask a Question