Re: Script to list patches applied to system (338 Views)
Reply
Trusted Contributor
Charles Holland
Posts: 257
Registered: ‎02-27-1997
Message 1 of 8 (338 Views)
Accepted Solution

Script to list patches applied to system

Ok, I have been able to come up with half of the script I'm trying to come up with.

Background:
When applying patches to the system, and after I go through matching what target has, it selects what patches should be applied. At this point I cancel back to the main window and the print to a file the list of patches that are going to be applied.

From this point I grep through the file looking for "Partial" or "Yes" and if I find it I write file "A". I then cat file "A" and pipe it to awk printing only the patch identifiers into a file. My problem comes in the next step when I want to take that file and instead of having one file with 20 rows, have one file with one row of all patches strung together. I can then copy this string of characters and put it into an excel spreadsheet.

Any Ideas?

Regards
"Not everything that can be counted counts, and not everything that counts can be counted" A. Einstein
Honored Contributor
Sridhar Bhaskarla
Posts: 6,350
Registered: ‎08-15-2001
Message 2 of 8 (338 Views)

Re: Script to list patches applied to system

Hi,

Post your script for more appropriate answers.

If I understood your message correctly, you are creating a file with the contents like

PHCO_21000
PHCO_22000
PHNE_23000
etc., and you want the output to be PHCO_21000 PHCO_22000 PHNE_23000 etc.,

A quick and dirty way is to use something like this

while read line
do
printf "$line " >> outfile
done < your_file
printf "\n:" >> outfile

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Honored Contributor
Bill Costigan
Posts: 1,427
Registered: ‎09-19-2000
Message 3 of 8 (338 Views)

Re: Script to list patches applied to system

Can you change the awk print to printf and use a tab or such instead of the new line at the end of each print.

e.g printf "%s \t" $1

Honored Contributor
Geoff Wild
Posts: 7,170
Registered: ‎06-04-2001
Message 4 of 8 (338 Views)

Re: Script to list patches applied to system

Try sed - something like this to join all lines:

sed :a;$!N;s/\n//;ta; INFILE > OUTFILE

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Trusted Contributor
Charles Holland
Posts: 257
Registered: ‎02-27-1997
Message 5 of 8 (338 Views)

Re: Script to list patches applied to system

To all:

Yes Sri the input file is exactly as you indicate.

Here is what I have so far, also incorperating printf instead of only print.

grep -i -e partial -e yes print_info|awk '{ printf $2 }'

this results in:

PHCO_27138PHCO_29072PHCO_29675PHCO_29692PHCO_29816PHCO_29829PHCO_29833PHCO_29895
PHCO_29905PHCO_30075PHCO_30243PHCO_30275PHCO_30361PHCO_30397PHCO_30402PHCO_30420

So close..... I need to get a space or comma or tab between them. I have tried Bill's suggestion but must have something "out of whack".
"Not everything that can be counted counts, and not everything that counts can be counted" A. Einstein
Honored Contributor
Patrick Wallek
Posts: 13,777
Registered: ‎06-21-2000
Message 6 of 8 (338 Views)

Re: Script to list patches applied to system

Try this:

grep -i -e partial -e yes print_info|awk '{ printf "%s ",$2 }'

Note that there is a between the s and the ". That will get you the space you need between the elements.
Honored Contributor
Sridhar Bhaskarla
Posts: 6,350
Registered: ‎08-15-2001
Message 7 of 8 (338 Views)

Re: Script to list patches applied to system

Hi,

Modify it as


grep -i -e partial -e yes print_info|awk '{ printf "%s ", $2}'

There is a space after s.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Trusted Contributor
Charles Holland
Posts: 257
Registered: ‎02-27-1997
Message 8 of 8 (338 Views)

Re: Script to list patches applied to system

Thanks to all that responded. I now have what I needed.
"Not everything that can be counted counts, and not everything that counts can be counted" A. Einstein
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.