Operating System - HP-UX
1748169 Members
4097 Online
108758 Solutions
New Discussion юеВ

Re: Script to list patches applied to system

 
SOLVED
Go to solution
Charles Holland
Trusted Contributor

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
7 REPLIES 7
Sridhar Bhaskarla
Honored Contributor

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
Bill Costigan
Honored Contributor

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

Geoff Wild
Honored Contributor

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.
Charles Holland
Trusted Contributor

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
Patrick Wallek
Honored Contributor
Solution

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.
Sridhar Bhaskarla
Honored Contributor

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
Charles Holland
Trusted Contributor

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