LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-07-2010, 04:25 AM   #1
kailash19
LQ Newbie
 
Registered: Apr 2010
Location: Pune
Posts: 13

Rep: Reputation: 0
Trying to find lsof version information


Hi ALL,

I am running a script on several hundred boxes and trying to fing the version of lsof they have.
I have created a scipr for that which runs "lsof -v" through ssh on those boxes.
I am taking output as: line=`lsof -v | sed '/^$/d' | grep "revision"`
echo $line.

But $line is not storing anything?? i dont know why, i think the control is not passing to script , after lsof is run.
How can i do that.

Appreciate your help in this regard.
 
Old 04-07-2010, 04:52 AM   #2
scobiej
Member
 
Registered: Aug 2003
Location: London
Distribution: Redhat, SuSE, Ubuntu
Posts: 75

Rep: Reputation: 15
Redirection

You need to redirect stderr for this to work.

line=`lsof -v 2>&1 | sed '/^$/d' | grep "revision"`
echo $line

Example output :-

revision: 4.80 latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ compiler version: 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux)
 
Old 04-07-2010, 05:45 AM   #3
kailash19
LQ Newbie
 
Registered: Apr 2010
Location: Pune
Posts: 13

Original Poster
Rep: Reputation: 0
Hi,

Thanks scobiej.Its working

Can you explain why we need to do that?
 
Old 04-07-2010, 05:52 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Because the version info is "debug" output, it's not lsof's core
business. You would have noticed that when you run your command
w/o assigning it to a variable that the "grep" doesn't seem to
take, and that you get a whole lot of info?



Cheers,
Tink
 
Old 04-07-2010, 06:20 AM   #5
kailash19
LQ Newbie
 
Registered: Apr 2010
Location: Pune
Posts: 13

Original Poster
Rep: Reputation: 0
Ok. Thanks for the help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the version information of installed libraries say for example libdec2.a atulspma AIX 6 05-31-2017 08:32 PM
RHEL version information arghyadas Red Hat 2 04-02-2010 03:31 AM
Find out the version information of installed libraries on AIX atulspma AIX 0 04-06-2009 03:22 AM
How to find out indone information and datablocks information in a file system chaitanya1982 Linux - Newbie 1 09-24-2008 02:58 AM
Version Information moetjojo Linux - Newbie 2 09-19-2002 04:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration