- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- UNIX95= and ps command dropping lines
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2006 07:36 AM
10-16-2006 07:36 AM
UNIX95= and ps command dropping lines
Here is an example of what I'm talking about.
Command line output
(fin_hp11 fin11c03) $ ps -ef | grep tgcgs
tgcgs 15109 1 0 Sep 9 ? 1:11 fics -LI 7 -v
tgcgs 15294 15109 0 Sep 9 ? 0:00 fics -LI 7 -v
tgcgs 15494 1 0 Sep 9 ? 0:47 oraclefin11t01 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
fin23127 25031 20864 1 11:43:39 pts/1 0:00 grep tgcgs
(fin_hp11 fin11c03) $ UNIX95= ps -A -o ruser,time,comm,args | grep tgcgs
tgcgs 01:11 fics fics -LI 7 -v
tgcgs 00:00 fics fics -LI 7 -v
tgcgs 00:47 oraclefin11t01 oraclefin11t01 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
fin23127 00:00 grep grep tgcgs
Here is the output from the Perl script.
(fin_hp11 fin11c03) $ cpu_usage
input line is tgcgs 01:11 fics fics -LI 7 -v
input line is tgcgs 00:00 fics fics -LI 7 -v
tgcgs: 2 71
User is tgcgs and CPU time used is 0 days 0 hours 1 minutes 11 seconds
As you can see the grep line is gone and that it expected. However, the process showing the connection to the Oracle database is gone too and that isn't expected.
Here is the command from within the Perl script. Once this is resolved the grep and grep -v will not exist in this command. They only exist here for testing purposes.
{ open (PROCESSES, "UNIX95= ps -e -o user,time,comm,args | grep tgcgs | grep -v grep |") or die "Cannot execute the ps command\n";
}
Thanks in advance for any assistance you can provide.
Chris Sarjent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2006 07:43 AM
10-16-2006 07:43 AM
Re: UNIX95= and ps command dropping lines
UNIX95= ps -u tgcgs -o user,time,comm,args
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2006 07:51 AM
10-16-2006 07:51 AM
Re: UNIX95= and ps command dropping lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2006 08:11 AM
10-16-2006 08:11 AM
Re: UNIX95= and ps command dropping lines
One other thought -- logically run through your script just to make sure it isn't accidentally ignoring the last line of input. I've run into situations like that once or twice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2006 08:19 AM
10-16-2006 08:19 AM
Re: UNIX95= and ps command dropping lines
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2006 08:23 AM
10-16-2006 08:23 AM
Re: UNIX95= and ps command dropping lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2006 09:11 AM
10-16-2006 09:11 AM
Re: UNIX95= and ps command dropping lines
"UNIX95= ps -e -o user,time,comm,args | grep tgcgs | grep -v grep |"
will always be erratic in operation. grep has no concept of a field -- it is just matching strings. So a user might be named bill but your script will match billh and billng and waybill and billy, thus retrieving incorrect matches. And bill could be contained in the command line arguments.
ps knows user names exactly (no wrong matches) and can have a long list in the -U option such as:
-U bill,joe,ashley,darren,ellen,bob,bobo
Also, it isn't clear in the man page but you can assign the -o options a new column heading INCLUDING nothing. Also, -o comm is a subset of -o args but if you need to isolate the actual command, you can use both, but args must be last. So if your line is something like:
"UNIX95= ps -U bill,joe,ashley,darren,ellen,bob,bobo -o user= -o time= -o comm= -o args="
Now you won't have to filter out the header line and you'll get all the selected users. The problem with -e is that you also get all the junk from root and other system and application processes.
Bill Hassell, sysadmin