Sponsored Content
Full Discussion: awk completes early
Top Forums Shell Programming and Scripting awk completes early Post 302129304 by nhatch on Monday 30th of July 2007 10:47:11 AM
Old 07-30-2007
awk completes early

Hi All.....

I have a text file with a good number of rows, example below. The script is to work out percent of failures. The problem I have is that the script exits after the first result is given. From this example here I should have two output lines, one from GetOffers and ListOffers. Any idea why this may be?

Quote:
(I) Jul 27 09:18:44:900 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1: Service[ListOffers] started
(I) Jul 27 09:19:01:220 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1: service [GetOffers] returns [0]
(I) Jul 27 09:19:28:777 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1 : Service[ListOffers] started
(I) Jul 27 09:19:32:698 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1 : service[ListOffers] returns [-1]
(I) Jul 27 09:19:48:878 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1 : Service[ListOffers] started
(I) Jul 27 09:19:51:316 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1 : service[ListOffers] returns [0]

Code:
percent()
{

awk -- 'BEGIN{EQUATION='"$*"';printf("%0.1f%\n",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"

echo $line
#printf "\n"

done

}

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

done

 

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
script(1)							   User Commands							 script(1)

NAME
script - make record of a terminal session SYNOPSIS
script [-a] [filename] DESCRIPTION
The script utility makes a record of everything printed on your screen. The record is written to filename. If no file name is given, the record is saved in the file typescript. See WARNINGS. The script command forks and creates a sub-shell, according to the value of $SHELL, and records the text from this session. The script ends when the forked shell exits or when Control-d is typed. OPTIONS
The following option is supported: -a Appends the session record to filename, rather than overwriting it. NOTES
script places everything that appears on the screen in filename, including prompts. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) WARNINGS
script can pose a security risk when used in directories that are writable by other users (for example, /tmp), especially when run by a privileged user, that is, root. Be sure that typescript is not a link before running script. SunOS 5.10 30 Jan 2004 script(1)
All times are GMT -4. The time now is 02:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy