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
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-akq] [-t time] [file [command ...]] DESCRIPTION
The script utility makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. If the argument command is given, script will run the specified command with an optional argument vector instead of an interactive shell. The following options are available: -a Append the output to file or typescript, retaining the prior contents. -k Log keys sent to program as well as output. -q Run in quiet mode, omit the start and stop status messages. -t time Specify time interval between flushing script output file. A value of 0 causes script to flush for every character I/O event. The default interval is 30 seconds. The script ends when the forked shell (or command) exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-D (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. The script utility works best with commands that do not manipulate the screen. The results are meant to emulate a hardcopy terminal, not an addressable one. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism). HISTORY
The script command appeared in 3.0BSD. BUGS
The script utility places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. It is not possible to specify a command without also naming the script file because of argument parsing compatibility issues. When running in -k mode, echo cancelling is far from ideal. The slave terminal mode is checked for ECHO mode to check when to avoid manual echo logging. This does not work when in a raw mode where the program being run is doing manual echo. BSD
January 22, 2004 BSD
All times are GMT -4. The time now is 04:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy