Sponsored Content
Top Forums Shell Programming and Scripting HELP PLEASE!! school assignment due in two hours!! Post 302193138 by hckygoli31 on Thursday 8th of May 2008 03:53:23 PM
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.$$
 

5 More Discussions You Might Find Interesting

1. 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

2. 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

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. 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

5. 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
FAXCRON(8)						      System Manager's Manual							FAXCRON(8)

NAME
faxcron - HylaFAX routine maintenance script SYNOPSIS
/usr/sbin/faxcron [ -n ] [ -l lastrun ] DESCRIPTION
faxcron is a command script that does routine upkeep tasks in a HylaFAX spooling directory hierarchy. This script is intended to be invoked from cron(8) on behalf of the fax user (often the ``fax'' user is uucp) once a day, with the standard output sent by mail to the HylaFAX administrator. For example, the following crontab might be set up for the fax user: 25 23 * * * sh /usr/sbin/faxcron | mail FaxMaster The faxcron script does the following work: o report statistics for facsimile transmitted since the last time faxcron was run. o report statistics for facsimile transmitted in the past week. o report statistics for facsimile received since the last time faxcron was run. o report statistics for facsimile received in the past week. o report any recent calls that failed suspiciously and return the associated trace log; o purge data that is 30 days or older from the remote machine information directory; o delete information that is 30 days or older from session trace log files; o remove files from the tmp directory that are older than 1 day; o remove files in the received facsimile queue that are 7 days or older; o report sites that are currently having jobs rejected; and o force all session log files to be owned by the fax user and kept with protection mode 644. OPTIONS
-n Forces faxcron to run without updating any files. -l lastrun Forces the notion of the last time that faxcron was run to be lastrun. The value of lastrun is a date and time string of the form ``MM/DD/YY HH:MM'' (the date(1) format string ``%D %H:%M''). -info n Set the expiration time for data in the info database to be n days. -log n Set the expiration time for session log data to be n days. -rcv n Set the expiration time for files in the received facsimile queue to be n days. -tmp n Set the expiration time for files in the tmp directory to be n days. -mode m Set the file protection mode for session logs to m (a command line argument to chmod(1)). NOTES
This script requires nawk(1) or gawk(1) and a date (1) program that supports the ``+format'' option. If session logs are to be kept private this script must be modified to filter out sensitive information such as calling card numbers. (It should also be run with ``-mode 0600'' so that session log files are not publicly readable.) FILES
/var/spool/hylafax spooling area /var/spool/hylafax/status/lastrun timestamp of last run /usr/sbin/xferfaxstats for generating transmit statistics /usr/sbin/recvstats for generating receive statistics /var/spool/hylafax/tmp/faxcronXXXX temporary file for truncating session logs /var/spool/hylafax/tmp/faxlogXXXX temporary file for logs of failed calls SEE ALSO
cron(8), faxq(8), faxgetty(8), faxsend(8), xferfaxstats(8), recvstats(8), hylafax-server(5) May 12, 1996 FAXCRON(8)
All times are GMT -4. The time now is 10:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy