LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices



Reply
 
Search this Thread
Old 06-15-2011, 11:49 AM   #1
Cpare
Member
 
Registered: Aug 2001
Location: Magic City, USA
Distribution: Ubuntu
Posts: 65

Rep: Reputation: 15
find command line switch value


I am creating a script to stop a service thats been running for too long, in this case however we want to call the vendors .sh which allows the appliction to shutdown gracefully (so a "kill-9" just isn't going to cut it).

To call the vendors .sh I need to pass it the "Name" of the server service (specified using the -name command line switch when starting the daemon). This value is visible when you do a "ps -ef", however it can fall in random places.

For example:

Code:
 boadmin 155984 328134   0 07:48:48      -  2:40 /opt/apps/busobj/bobj/bobje/enterprise120//aix_rs6000/WIReportServer -loggingPath /opt/apps/busobj/bobj/bobje/logging/ -fg -restart -name SIA_oianp140.WebIntelligenceProcessingServer5 -pidfile /opt/apps/busobj/bobj/bobje/serverpids/SIA_oianp140_SIA_oianp140.WebIntelligenceProcessingServer6.pid -ns oianp007:6400 -ns oianp007:6400
Any suggestions how I can "Find" the value after the "-name" command line option? do I need to throw the ps-ef results into an array, and then loop through it looking for the "-name" so i can take the next item in the array? That seems too complex IMHO, so I thought I would ask before trying to reinvent the wheel.

Thanks!
 
Old 06-15-2011, 12:00 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
You can try with awk:
Code:
ps -C WIReportServer -o args | awk 'BEGIN{RS=" "}/-name/{getline; print}'
not sure if the ps command on AIX accepts the option -o args, but you can put your own ps command here to extract the wanted line. The awk part puts all the space-separated fields on different lines and prints out the line that immediately follows the -name option.
 
1 members found this post helpful.
Old 06-16-2011, 04:44 PM   #3
Cpare
Member
 
Registered: Aug 2001
Location: Magic City, USA
Distribution: Ubuntu
Posts: 65

Original Poster
Rep: Reputation: 15
Thanks for this suggestion, I ended up with the following line in my .sh
Code:
strBOBJName=`ps -ef |grep ${arrDaemonPIDList[i]} | awk 'BEGIN{RS=" "}/-name/{getline; print}'`
 
  


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 switch to command line from GUI using keyboard shortcut tj_linux Linux - Newbie 16 05-16-2010 08:29 AM
LXer: Switch to the Command Line, Part 1. LXer Syndicated Linux News 1 05-13-2009 05:07 AM
Help Please!! -- need to find command that will switch you back to your previous CWD Tron55555 Linux - General 2 05-15-2008 11:35 PM
How to switch an application from one desktop to another using command line demianxyz Linux - Software 2 10-15-2006 07:36 PM
How switch from x-window to the command line backpacker Linux - Newbie 1 06-09-2005 04:56 AM


All times are GMT -5. The time now is 03:30 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration