Sponsored Content
Full Discussion: awk completes early
Top Forums Shell Programming and Scripting awk completes early Post 302129884 by nhatch on Thursday 2nd of August 2007 05:34:06 AM
Old 08-02-2007
Thanks for the reply...I did try the awk method but got only error messages.

I'm still struggling but now get another issue that i can't figure out. I have suplied the full script I have written. The new problem is that when the daily percentage of failures is worked out it doesn't return to the command prompt after giving the percent result. If I check the processes running it still has the percent function running. I can't figure what it is waiting on.



Code:
#set -x

# Usage

usage()
{
echo "
        Usage:check_CCOS_actions -f <file name> -ohd

        Where.....

        o - Failure by order type
        h - Failure by hour
        d - Failure by day
     "
exit 1
}

percent()
{
awk 'BEGIN{EQUATION='"$*"' ;printf("%0.1f%",EQUATION)}'
}

order()
{
echo Start ordering

grep "] started" $file | awk '{print $10}' | sort | uniq | while read line
do

line=${line#\[}
line=${line%]}

started=`grep "] started" $file | grep -c $line`
returns=`grep "returns \[" $file | grep -c $line`
failreturn=`grep "returns \[-1" $file | grep -c $line`

printf "Fail percent on $line = \c"

percent "$failreturn / $returns * 100"
done
}

hourly()
{
echo nothing
}

day()
{

started=`grep -c "] started" $file`
returns=`grep -c "returns \[" $file`
failreturn=`grep -c "returns \[-1" $file`

printf "Fail Percent to date = \c"
percent "$failreturn / $returns * 100"

#exit 0
}

while getopts f:od name
do
        case $name in
                f)
                        file="$OPTARG";;
                o)
                 order;;
                d)
                 day;;
                h)
                 hourly;;
                *)
                 usage;;
        esac

done

if [ "$file" = "" ]
then
        usage
fi

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append Status to echo'd line after process completes

Hello All, I'm very new to scripting and I'm writing a very simple script to restart a couple processes because I'm getting to lazy to cd between directories. This is pretty much my first script and I just want to add a little cosmetics to it. Here's what I have: #!/bin/ksh echo... (5 Replies)
Discussion started by: Setan
5 Replies

2. Shell Programming and Scripting

remove directory x seconds after script completes

Hi guys, I am working with a script within a Mac OS X package installer. The package installer will run the bash script once the files have been copied/installed. I have a little trouble with the last line of my script causing the package installer to crash once in a while and I have narrowed it... (1 Reply)
Discussion started by: tret
1 Replies

3. UNIX for Advanced & Expert Users

how to delay a process getting killed before it completes its work

The problem i am encountering is the process is getting killed before it dispalys the details.The details are displayed using printf.I created a new buffer for printing the details using setvbuf function call instead of output buffer.This is not working.The thing is,killing of the process must be... (1 Reply)
Discussion started by: cijkmysj
1 Replies

4. UNIX Benchmarks

Early PowerMac G5

Hardware Overview: Model Name: Power Mac G5 Model Identifier: PowerMac7,2 Processor Name: PowerPC 970 (2.2) Processor Speed: 1.8 GHz Number Of CPUs: 2 L2 Cache (per CPU): 512 KB Memory: 1.5 GB Bus Speed: 900 MHz Boot ROM Version:... (0 Replies)
Discussion started by: tnorth
0 Replies

5. Shell Programming and Scripting

Read file contents and separate the lines when completes with =

Hi, I have a file like this cpsSystemNotifyTrap='2010/12/14 11:05:31 CST' Manufacturer=IBM ReportingMTMS=n/a ProbNm=26 LparName=n/a FailingEnclosureMTMS=7946-IQL*99G4874 SRC=B3031107 EventText=Problem reported by customer. CallHome=true Calendar I want to have a output like this... (6 Replies)
Discussion started by: dbashyam
6 Replies

6. Shell Programming and Scripting

While loop - how to run processes one after another (2nd starts after first completes, and so on)

I'm a programming noob. I'm trying to run a memory intensive process for many files. But when I use the following script, it runs fine for the first 5-7 files, then runs out of memory. Monitoring the output files, it's clear the processes are going on in parallel. Once 5-7 of the files are being... (18 Replies)
Discussion started by: pathunkathunk
18 Replies

7. Shell Programming and Scripting

<< Environmental Variables are not set when script completes >>

Hi Team, I have a wrapper script which i have pasted below, it internally calls one python script to generate Environmental in a file called /home/oracle/myenv.sh, when i execute this script via wrapper script, its not reflecting in my current session, still showing old env variables. any... (2 Replies)
Discussion started by: kamauv234
2 Replies
ZGREP(1)						    BSD General Commands Manual 						  ZGREP(1)

NAME
zgrep, zegrep, zfgrep -- print lines matching a pattern in gzip-compressed files SYNOPSIS
zgrep [grep-flags] [--] pattern [files ...] zegrep [grep-flags] [--] pattern [file ...] zfgrep [grep-flags] [--] pattern [file ...] DESCRIPTION
zgrep runs grep(1) on files or stdin, if no files argument is given, after decompressing them with zcat(1). The grep-flags and pattern arguments are passed on to grep(1). If an -e flag is found in the grep-flags, zgrep will not look for a pattern argument. zegrep calls egrep(1), while zfgrep calls fgrep(1). EXIT STATUS
In case of missing arguments or missing pattern, 1 will be returned, otherwise 0. SEE ALSO
egrep(1), fgrep(1), grep(1), gzip(1), zcat(1) AUTHORS
Thomas Klausner <wiz@NetBSD.org> BSD
December 28, 2003 BSD
All times are GMT -4. The time now is 10:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy