Sponsored Content
Full Discussion: ps-u
Top Forums UNIX for Dummies Questions & Answers ps-u Post 302237710 by Source2Exe on Thursday 18th of September 2008 08:07:50 AM
Old 09-18-2008
In most cases, this should do the trick (Linux Bash):

1. In Linux, you might want to get rid of the "-" in "ps -u" and just use "ps u" or you will get a warning message.

2. Count how many lines are presented before the actual list of processes produced by ps -u. Normally its 1, but could be 2 or more.

2. This example assumes 2 lines of text before the actual process data:
Code:
echo $[`ps u | wc -l`-2]


Last edited by Source2Exe; 09-18-2008 at 09:12 AM..
 
IO::Async::Protocol::LineStream(3pm)			User Contributed Perl Documentation		      IO::Async::Protocol::LineStream(3pm)

NAME
"IO::Async::Protocol::LineStream" - stream-based protocols using lines of text SYNOPSIS
Most likely this class will be subclassed to implement a particular network protocol. package Net::Async::HelloWorld; use strict; use warnings; use base qw( IO::Async::Protocol::LineStream ); sub on_read_line { my $self = shift; my ( $line ) = @_; if( $line =~ m/^HELLO (.*)/ ) { my $name = $1; $self->invoke_event( on_hello => $name ); } } sub send_hello { my $self = shift; my ( $name ) = @_; $self->write_line( "HELLO $name" ); } This small example elides such details as error handling, which a real protocol implementation would be likely to contain. DESCRIPTION
EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters: on_read_line $line Invoked when a new complete line of input is received. PARAMETERS
The following named parameters may be passed to "new" or "configure": on_read_line => CODE CODE reference for the "on_read_line" event. METHODS
$lineprotocol->write_line( $text ) Writes a line of text to the transport stream. The text will have the end-of-line marker appended to it; $text should not end with it. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Protocol::LineStream(3pm)
All times are GMT -4. The time now is 02:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy