Unix Technical Forum

Scipting

This is a discussion on Scipting within the AIX Operating System forums, part of the Unix Operating Systems category; --> I'm trying to write a script to check version of filesets, however, when I run lslpp -l|grep krb5, it ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 12:51 PM
KB
 
Posts: n/a
Default Scipting

I'm trying to write a script to check version of filesets, however,
when I run lslpp -l|grep krb5, it shows multiple lines of the same
output:

root@rs239md03:lslpp -l|grep krb5
krb5.client.rte 1.4.0.4 COMMITTED Network
Authentication Service
krb5.client.samples 1.4.0.4 COMMITTED Network
Authentication Service
krb5.doc.en_US.html 1.4.0.4 COMMITTED Network Auth Service
HTML
krb5.doc.en_US.pdf 1.4.0.4 COMMITTED Network Auth Service
PDF
krb5.lic 1.4.0.4 COMMITTED Network
Authentication Service
krb5.server.rte 1.4.0.4 COMMITTED Network
Authentication Service
krb5.toolkit.adt 1.4.0.4 COMMITTED Network
Authentication Service
krb5.client.rte 1.4.0.4 COMMITTED Network
Authentication Service
krb5.server.rte 1.4.0.4 COMMITTED Network
Authentication Service

when I try to script this to grab jsut that one variable (1.4.0.4) it
grabs every instance:

root@rs239md03:x=`lslpp -l|grep krb5 | awk '{print $2}'`
root@rs239md03:echo $x
1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4
1.4.0.4

what I'm trying to do si modify the variable to grab just ONE instance
of the version and save it to the variable..
root@rs239md03:echo $x
1.4.0.4

what do I need to do?

thanks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 12:51 PM
Paul Landay
 
Posts: n/a
Default Re: Scipting

KB wrote:
> I'm trying to write a script to check version of filesets, however,
> when I run lslpp -l|grep krb5, it shows multiple lines of the same
> output:
>
> root@rs239md03:lslpp -l|grep krb5
> krb5.client.rte 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.client.samples 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.doc.en_US.html 1.4.0.4 COMMITTED Network Auth Service
> HTML
> krb5.doc.en_US.pdf 1.4.0.4 COMMITTED Network Auth Service
> PDF
> krb5.lic 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.server.rte 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.toolkit.adt 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.client.rte 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.server.rte 1.4.0.4 COMMITTED Network
> Authentication Service
>
> when I try to script this to grab jsut that one variable (1.4.0.4) it
> grabs every instance:
>
> root@rs239md03:x=`lslpp -l|grep krb5 | awk '{print $2}'`
> root@rs239md03:echo $x
> 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4
> 1.4.0.4
>
> what I'm trying to do si modify the variable to grab just ONE instance
> of the version and save it to the variable..
> root@rs239md03:echo $x
> 1.4.0.4
>
> what do I need to do?
>
> thanks
>

It is not 'multiple lines of the same output'.
It is one line per fileset with 'krb5' in the name
(and potentially a root,usr,share part per
fileset name).

In your example all the *krb5* filesets are at
the 1.4.0.4 level, but that is not guaranteed
to always be true.

If you just want the version from one fileset,
do the lslpp query on that one fileset name
and use the 'lslpp -O' flag to specify which
fileset part to query. For example:
lslpp -O u -l krb5.client.rte
These flags are described in 'man lslpp'.

Paul Landay
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 12:51 PM
KB
 
Posts: n/a
Default Re: Scipting

On Aug 2, 5:37 pm, Paul Landay <lan...@attglobal.net> wrote:
> KB wrote:
> > I'm trying to write a script to check version of filesets, however,
> > when I run lslpp -l|grep krb5, it shows multiple lines of the same
> > output:

>
> > root@rs239md03:lslpp -l|grep krb5
> > krb5.client.rte 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.client.samples 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.doc.en_US.html 1.4.0.4 COMMITTED Network Auth Service
> > HTML
> > krb5.doc.en_US.pdf 1.4.0.4 COMMITTED Network Auth Service
> > PDF
> > krb5.lic 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.server.rte 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.toolkit.adt 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.client.rte 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.server.rte 1.4.0.4 COMMITTED Network
> > Authentication Service

>
> > when I try to script this to grab jsut that one variable (1.4.0.4) it
> > grabs every instance:

>
> > root@rs239md03:x=`lslpp -l|grep krb5 | awk '{print $2}'`
> > root@rs239md03:echo $x
> > 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4
> > 1.4.0.4

>
> > what I'm trying to do si modify the variable to grab just ONE instance
> > of the version and save it to the variable..
> > root@rs239md03:echo $x
> > 1.4.0.4

>
> > what do I need to do?

>
> > thanks

>
> It is not 'multiple lines of the same output'.
> It is one line per fileset with 'krb5' in the name
> (and potentially a root,usr,share part per
> fileset name).
>
> In your example all the *krb5* filesets are at
> the 1.4.0.4 level, but that is not guaranteed
> to always be true.
>
> If you just want the version from one fileset,
> do the lslpp query on that one fileset name
> and use the 'lslpp -O' flag to specify which
> fileset part to query. For example:
> lslpp -O u -l krb5.client.rte
> These flags are described in 'man lslpp'.
>
> Paul Landay- Hide quoted text -
>
> - Show quoted text -


I just want to print the vaule of $2 (which will be 1.4.0.4) and have
a if statement to look at this variable. So far, it picks up all or
nothing...
x=`lslpp -l|grep krb5 | awk '{print $2}'`

if [ $x = '1.4.0' ];then
echo "$x Kerberos is installed on `hostname` "
else
echo "Kerberos needs to be installed on `hostname` "
fi

echo " "
EOF
done >$LF


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-05-2008, 12:51 PM
Henry
 
Posts: n/a
Default Re: Scipting

On Aug 3, 10:01 am, KB <ucst...@hotmail.com> wrote:
> I'm trying to write a script to check version of filesets, however,
> when I run lslpp -l|grep krb5, it shows multiple lines of the same
> output:
>
> root@rs239md03:lslpp -l|grep krb5
> krb5.client.rte 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.client.samples 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.doc.en_US.html 1.4.0.4 COMMITTED Network Auth Service
> HTML
> krb5.doc.en_US.pdf 1.4.0.4 COMMITTED Network Auth Service
> PDF
> krb5.lic 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.server.rte 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.toolkit.adt 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.client.rte 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.server.rte 1.4.0.4 COMMITTED Network
> Authentication Service
>
> when I try to script this to grab jsut that one variable (1.4.0.4) it
> grabs every instance:
>
> root@rs239md03:x=`lslpp -l|grep krb5 | awk '{print $2}'`
> root@rs239md03:echo $x
> 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4
> 1.4.0.4
>
> what I'm trying to do si modify the variable to grab just ONE instance
> of the version and save it to the variable..
> root@rs239md03:echo $x
> 1.4.0.4
>
> what do I need to do?
>
> thanks

Hi there
I assume your question is "what version of Kerberos do I have
installed?"
I don't have Kerberos installed at all but this may help

lslpp -lc sysmgt.websm* | awk -F':' '!/^#Fileset/{print $3}' | sort -
nr | uniq


just replace "sysmgt.websm*" with "krb5*" and see what you get.

The "lsauthent" command may also be helpful. Found kerberos info' here

http://publib.boulder.ibm.com/infoce...nformation.htm

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-05-2008, 12:51 PM
Dieter Stumpner
 
Posts: n/a
Default Re: Scipting

KB wrote:
>
> I just want to print the vaule of $2 (which will be 1.4.0.4) and have
> a if statement to look at this variable. So far, it picks up all or
> nothing...
> x=`lslpp -l|grep krb5 | awk '{print $2}'`
>
> if [ $x = '1.4.0' ];then
> echo "$x Kerberos is installed on `hostname` "
> else
> echo "Kerberos needs to be installed on `hostname` "
> fi
>
> echo " "
> EOF
> done >$LF
>

If your output could have more than one line use echo "$x" (with quote).

next step is to determine which line you need.
first line: echo "$x" | head -n 1
last line: echo "$x" | tail -n 1
3rd line: echo "$x" | head -n 3 | tail -n 1 (i am sure awk/sed/...
could do that better)
all lines: for I in "$x" do ; echo "my version $I"; done

with best regards
Dieter Stumpner
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-05-2008, 12:51 PM
F. Michael Orr
 
Posts: n/a
Default Re: Scipting

On Fri, 03 Aug 2007 09:09:12 +0200, Dieter Stumpner wrote:

> KB wrote:
>>
>> I just want to print the vaule of $2 (which will be 1.4.0.4) and have a
>> if statement to look at this variable. So far, it picks up all or
>> nothing...
>> x=`lslpp -l|grep krb5 | awk '{print $2}'`
>>
>> if [ $x = '1.4.0' ];then
>> echo "$x Kerberos is installed on `hostname` "
>> else
>> echo "Kerberos needs to be installed on `hostname` "
>> fi
>>
>> echo " "
>> EOF
>> done >$LF
>>

> If your output could have more than one line use echo "$x" (with quote).
>
> next step is to determine which line you need. first line: echo "$x" |
> head -n 1
> last line: echo "$x" | tail -n 1
> 3rd line: echo "$x" | head -n 3 | tail -n 1 (i am sure awk/sed/...
> could do that better)
> all lines: for I in "$x" do ; echo "my version $I"; done
>
> with best regards
> Dieter Stumpner


Why not just use 'lslpp -lc'?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-05-2008, 12:51 PM
aixdude@yahoo.com
 
Posts: n/a
Default Re: Scipting

On Aug 2, 6:01 pm, KB <ucst...@hotmail.com> wrote:
> I'm trying to write a script to check version of filesets, however,
> when I run lslpp -l|grep krb5, it shows multiple lines of the same
> output:
>
> root@rs239md03:lslpp -l|grep krb5
> krb5.client.rte 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.client.samples 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.doc.en_US.html 1.4.0.4 COMMITTED Network Auth Service
> HTML
> krb5.doc.en_US.pdf 1.4.0.4 COMMITTED Network Auth Service
> PDF
> krb5.lic 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.server.rte 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.toolkit.adt 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.client.rte 1.4.0.4 COMMITTED Network
> Authentication Service
> krb5.server.rte 1.4.0.4 COMMITTED Network
> Authentication Service
>
> when I try to script this to grab jsut that one variable (1.4.0.4) it
> grabs every instance:
>
> root@rs239md03:x=`lslpp -l|grep krb5 | awk '{print $2}'`
> root@rs239md03:echo $x
> 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4
> 1.4.0.4
>
> what I'm trying to do si modify the variable to grab just ONE instance
> of the version and save it to the variable..
> root@rs239md03:echo $x
> 1.4.0.4
>
> what do I need to do?
>
> thanks



what about lslpp -L then grep

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-05-2008, 12:51 PM
KB
 
Posts: n/a
Default Re: Scipting

On Aug 3, 2:59 pm, "aixd...@yahoo.com" <aixd...@yahoo.com> wrote:
> On Aug 2, 6:01 pm, KB <ucst...@hotmail.com> wrote:
>
>
>
>
>
> > I'm trying to write a script to check version of filesets, however,
> > when I run lslpp -l|grep krb5, it shows multiple lines of the same
> > output:

>
> > root@rs239md03:lslpp -l|grep krb5
> > krb5.client.rte 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.client.samples 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.doc.en_US.html 1.4.0.4 COMMITTED Network Auth Service
> > HTML
> > krb5.doc.en_US.pdf 1.4.0.4 COMMITTED Network Auth Service
> > PDF
> > krb5.lic 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.server.rte 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.toolkit.adt 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.client.rte 1.4.0.4 COMMITTED Network
> > Authentication Service
> > krb5.server.rte 1.4.0.4 COMMITTED Network
> > Authentication Service

>
> > when I try to script this to grab jsut that one variable (1.4.0.4) it
> > grabs every instance:

>
> > root@rs239md03:x=`lslpp -l|grep krb5 | awk '{print $2}'`
> > root@rs239md03:echo $x
> > 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4
> > 1.4.0.4

>
> > what I'm trying to do si modify the variable to grab just ONE instance
> > of the version and save it to the variable..
> > root@rs239md03:echo $x
> > 1.4.0.4

>
> > what do I need to do?

>
> > thanks

>
> what about lslpp -L then grep- Hide quoted text -
>
> - Show quoted text -


those all work, however, what I want to do is run this script
enterprise wide and have it look for any kerberos version 1.4.x and if
it's installed, say its running and if it's not installed, say install
it. my script looks for that exact version of kerberos, however, if
I'm running 1.4.0.2 or 1.4.0.3, it will give a error even when I'm
looking for 1.4. HTH

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-05-2008, 12:51 PM
desas2@gmail.com
 
Posts: n/a
Default Re: Scipting

On Aug 3, 4:47 pm, KB <ucst...@hotmail.com> wrote:
> On Aug 3, 2:59 pm, "aixd...@yahoo.com" <aixd...@yahoo.com> wrote:
>
>
>
> > On Aug 2, 6:01 pm, KB <ucst...@hotmail.com> wrote:

>
> > > I'm trying to write a script to check version of filesets, however,
> > > when I run lslpp -l|grep krb5, it shows multiple lines of the same
> > > output:

>
> > > root@rs239md03:lslpp -l|grep krb5
> > > krb5.client.rte 1.4.0.4 COMMITTED Network
> > > Authentication Service
> > > krb5.client.samples 1.4.0.4 COMMITTED Network
> > > Authentication Service
> > > krb5.doc.en_US.html 1.4.0.4 COMMITTED Network Auth Service
> > > HTML
> > > krb5.doc.en_US.pdf 1.4.0.4 COMMITTED Network Auth Service
> > > PDF
> > > krb5.lic 1.4.0.4 COMMITTED Network
> > > Authentication Service
> > > krb5.server.rte 1.4.0.4 COMMITTED Network
> > > Authentication Service
> > > krb5.toolkit.adt 1.4.0.4 COMMITTED Network
> > > Authentication Service
> > > krb5.client.rte 1.4.0.4 COMMITTED Network
> > > Authentication Service
> > > krb5.server.rte 1.4.0.4 COMMITTED Network
> > > Authentication Service

>
> > > when I try to script this to grab jsut that one variable (1.4.0.4) it
> > > grabs every instance:

>
> > > root@rs239md03:x=`lslpp -l|grep krb5 | awk '{print $2}'`
> > > root@rs239md03:echo $x
> > > 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4 1.4.0.4
> > > 1.4.0.4

>
> > > what I'm trying to do si modify the variable to grab just ONE instance
> > > of the version and save it to the variable..
> > > root@rs239md03:echo $x
> > > 1.4.0.4

>
> > > what do I need to do?

>
> > > thanks

>
> > what about lslpp -L then grep- Hide quoted text -

>
> > - Show quoted text -

>
> those all work, however, what I want to do is run this script
> enterprise wide and have it look for any kerberos version 1.4.x and if
> it's installed, say its running and if it's not installed, say install
> it. my script looks for that exact version of kerberos, however, if
> I'm running 1.4.0.2 or 1.4.0.3, it will give a error even when I'm
> looking for 1.4. HTH


Try the following and hope that helps.
x=`lslpp -l|grep krb5 | awk '{print $2}'|uniq`

Thanks
Dinakar

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:02 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com