I am writing a script in which I need to gather 2 numbers for 'total' and 'successful'. The goal is to compare the two numbers and if they are not equal, rerun the task until all are successful. I'm thinking the best way will be with awk or sed, but I really don't know where to begin with this one.
The line that is outputted from the task is a very large single line with no spaces. However the beginning of the line appears to be consistent. Here is the output from my 4 manual runs:
As mentioned, it looks like the easiest way to test the need for rerunning is comparing the total and successful numbers.
Can anyone provide any guidance as to how to gather the 2 numbers and then do a loop to rerun the task until there are no errors?
Does the task not use an exit code ? You can test for it until it is succesful
This will run indefinitely if task will never be successful
Alternatively (bash/ksh) you can limit the number of attempts and report about them.
--
If there is no return code and testing the output is the only option, then I suggest testing for the number of fails :
Likewise, you can use
in the second example...
Last edited by Scrutinizer; 08-26-2018 at 05:41 AM..
This User Gave Thanks to Scrutinizer For This Post:
If task doesn't return a useful exit code (i.e., always returns a zero exit status), one could still skip parsing counts and just loop until success is found:
This User Gave Thanks to Don Cragun For This Post:
RudiC thank you for that suggestion of: 'grep -Eo'... It allowed me to get it working with:
This appears to be doing the trick. If there is something really wrong with this approach please let me know. Like most of the scripts I write, they start off 'working' and I improve the efficiency with time ;-) ...
Thanks again scrutinizer, Don Cragun, and RudiC.. Much appreciated.
Hi,
I need a help on my requirement that
eg: NEED="TEST=Name WORK=Ps DEL=let"
Here the definition can be n number, could anybody have an idea to get the output as,
TEST=Name
WORK=Ps
DEL=let
..
..
till the 'n' definitions listed.
Any suggestions please.....
Regards,
ricky (6 Replies)
Below code extracts multiple field values from XML into array and prints all in one line.
perl -nle '@r=/(?: jndiName| authDataAlias| value| minConnections| maxConnections| connectionTimeout| name)="(+)/g and print join ",",$ENV{tIPnSCOPE},$ENV{pr
ovider},$ENV{impClassName},@r' server.xml
... (4 Replies)
Hi All,
I have a file with long list of numbers. This file contains only one column. These numbers are very large. I am using following command:
cat myfile.txt | awk '{ sum+=$1} END {print sum}'
The output is coming in scientific notation. How do I get the result in proper format?
... (4 Replies)
I hope to create a file made up of 2 columns
- first column print out number 0~61000 every 50 of it
- second column just contains 0
delineated by space
such as
0 0
50 0
100 0
150 0
200 0
...
60900 0
60950 0
61000 0
Which command should I need to use? I think I might need to use... (5 Replies)
I have a single line file like this :
Average Fragmentation Quotient : 3.084121
Now I want to store the value which comes after ":" i,e 3.084121 into a variable.
And if this variable crosses above 6 i want to call another script...
can any one help me on this... (7 Replies)
I have a file that needs to be parsed into multiple files every time there line contains a number 1. the problem i face is the lines are random and the file size is random. an example is that on line 4, 65, 187, 202 & 209 are number 1's so there has to be file breaks between all those to create 4... (6 Replies)
Hi All,
I am just curious, not programming anything of my own. I know there are libraries like gmp which does all such things. But I really need to know HOW they do all such things i.e. working with extremely large unimaginable numbers which are beyond the integer limit. They can do add,... (1 Reply)
Hi
I have a big file with a certain pattern (shown below) from which I need to parse out some digits in tabular format.
The format of the file is: '-' indicates text which doesn't to be parsed
# Output of huzzle for sequence file 1000.Clade1.html
- - - -- -------... (2 Replies)
Hi
I have a single large file 11gb that I need to copy/backup to tape then restore on another system. I tried tar but that complained about the file being too large
Anyone have any suggestions how I can do this with AIX 5.2
Much appreciated. (3 Replies)
I am trying to parse hundreds of shell scripts to determine how they related to each other. Ideally for every script, I would get an output of:
What other scripts it calls
What files it reads
Environment variables it accesses
Any ideas on how to do this?
TIA! (2 Replies)