1756713 Members
2498 Online
108852 Solutions
New Discussion юеВ

Re: Output redirection

 
sen_ux
Valued Contributor

Output redirection

Hello,

I need to redirect check_patches output to a file.Is there any way to get it as it apprears on the screen.When I diect with '>' it is giving scattered o/p as the count increases.

Thanks,
sen


6 REPLIES 6
Jeeshan
Honored Contributor

Re: Output redirection

>>When I diect with '>' it is giving scattered o/p as the count increases.


the thing is which format you wanna see the output. If you open it using note pad, the output will be scattered.

if you use windows word pad it will show you the exact way u have seen in HP-UX box's.
a warrior never quits
sen_ux
Valued Contributor

Re: Output redirection

Hi Ahsan,

I would like see the o/p like this.

Checking installed version of /usr/sbin/swconfig
Checking for invalid patches
Checking object module checksums for active patch fileset 783 of 783
Checking patch filesets for active patch 412 of 412
Checking state for patch fileset 1588 of 1588
Checking patch_state for patch fileset 1588 of 1588
Running swverify on all patch filesets, this may take several minute

It apprears like this on screen ( Using carriage return).

But if i redirect, each line will be printed.

Like this.

Checking object module checksums for active patch fileset 1 of 783
Checking object module checksums for active patch fileset 2 of 783
Checking object module checksums for active patch fileset 3 of 783
Checking object module checksums for active patch fileset 4 of 783
Checking object module checksums for active patch fileset 5 of 783
Checking object module checksums for active patch fileset 6 of 783
Checking object module checksums for active patch fileset 7 of 783
Checking object module checksums for active patch fileset 8 of 783
Checking object module checksums for active patch fileset 9 of 783
Checking object module checksums for active patch fileset 10 of 783
Checking object module checksums for active patch fileset 11 of 783
Checking object module checksums for active patch fileset 12 of 783

I hope u got what i need.
Is it stupid question.?

Regds
Sen
Wouter Jagers
Honored Contributor

Re: Output redirection

Hiya,

Seen the above, I'm guessing that these lines are updated 'live' when you're running it without redirection. That would explain that, when you redirect the output, every update is written to your file.

I see that the check_patches utility logs all information to /tmp/check_patches.report. Maybe that file can help you out ?

Cheers,
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
Dennis Handly
Acclaimed Contributor

Re: Output redirection

>But if i redirect, each line will be printed.

That's why you redirect it. You can then edit the file as you like. Or you can write a script to delete the progress info:
grep -v "Checking object module checksums for active patch" file > file.new
Wouter Jagers
Honored Contributor

Re: Output redirection

Should you really want to use your output file and remove all but the last entries from the numbered list, try editing it.

# sed -n -e '
/[0-9][0-9]* of [0-9][0-9]*/ !{p;}
/\([0-9][0-9]*\) of \1/ {p;}
' outputfile > outputfile.new

..for example. There probably a bunch of ways to do it (sed,awk,perl,..)

Cheers,
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
James R. Ferguson
Acclaimed Contributor

Re: Output redirection

Hi Sen:

Wouter is correct. By design, 'check_patches' uses carriage-return characters to overwrite the lines it produces to show the file counts on STDOUT (your terminal). Thus you see only a summary of each pass.

There is no need to redirect the output to a file for later viewing, since 'check_patches' automatically produces the file ' /tmp/check_patches.report' that summarizes the results and lists any issues found. This is documented in its manpages.

You won't see the same output in '/tmp/check_patches.report' that you do on your terminal, though. If you wanted both outputs, you could do:

# check_patches | tee /tmp/mycheckpatches
# perl -pi -e 's/\015/\012/g' /tmp/mycheckpatches

...now, the '/tmp/mycheckpatches' file will hold the details of what you saw on your terminal. You will still have the standard 'check_patches.report' too.

Regards!

...JRF...