Re: [ilugd] ps and grep

2008-01-21 Thread Alok G. Singh
On 17 Jan 2008, [EMAIL PROTECTED] wrote:

 Puneet I tried ps -elo pid,args|grep myprocess\\!(grep)

 The argument of grep is a regular expression (type 3 language), and
 there is no way you can do this in a type 3 language. Even 'grep' also
 matches 'grep' text when you pass '-v grep' argument to 'grep' command
 line, and then only outputs unmatched lines.

I used two pipes to eliminates the extraneous grep, until some pointed
out that all you need to do it make the regexp different from the
matched string, viz.

$ ps -e | grep [m]ysql

Elegant, I thought.

-- 
Alok

Why won't sharks eat lawyers?   Professional courtesy.


___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] ps and grep

2008-01-21 Thread Puneet Lakhina
On Jan 21, 2008 4:53 PM, Alok G. Singh [EMAIL PROTECTED] wrote:


 I used two pipes to eliminates the extraneous grep, until some pointed
 out that all you need to do it make the regexp different from the
 matched string, viz.

 $ ps -e | grep [m]ysql


This is elegant. Thanks.


-- 
Puneet
http://sahyog.blogspot.com/
Latest Post: Tutorial on SVN setup and usage
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] ps and grep

2008-01-17 Thread Ashish Shukla आशीष शुक्ल
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 Puneet == Puneet Lakhina [EMAIL PROTECTED] writes:
Puneet Hi,
Puneet I have to frequently find the process ids of particular processes 
using a
Puneet combination of ps and grep.

You can try 'pidof'[1], if you're simply interested in find pid of a
process :)

[snipped]

Puneet But I was wondering if there was a way for me to specify this in 
the regular
Puneet expression for the first grep itself.

Puneet I tried ps -elo pid,args|grep myprocess\\!(grep)

The argument of grep is a regular expression (type 3 language), and
there is no way you can do this in a type 3 language. Even 'grep' also
matches 'grep' text when you pass '-v grep' argument to 'grep' command
line, and then only outputs unmatched lines.

References:
[1] - http://en.wikipedia.org/wiki/Pidof

HTH
- -- 
Ashish Shukla आशीष शुक्ल  http://wahjava.wordpress.com/
·-- ·-  ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHjxaoHy+EEHYuXnQRAhSeAJ9xqesGE9zmVAxwrra5qL2vK2Va3QCfbIIH
OGJttE+PSg5/oPivzZKcrBA=
=hoWY
-END PGP SIGNATURE-

___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] ps and grep

2008-01-17 Thread tuxdna
  Puneet == Puneet Lakhina [EMAIL PROTECTED] writes:
Puneet Hi,
Puneet I have to frequently find the process ids of particular
 processes using a
Puneet combination of ps and grep.

 You can try 'pidof'[1], if you're simply interested in find pid of a
 process :)

 [snipped]

Puneet But I was wondering if there was a way for me to specify this
 in the regular
Puneet expression for the first grep itself.

Puneet I tried ps -elo pid,args|grep myprocess\\!(grep)

 The argument of grep is a regular expression (type 3 language), and
 there is no way you can do this in a type 3 language. Even 'grep' also
 matches 'grep' text when you pass '-v grep' argument to 'grep' command
 line, and then only outputs unmatched lines.

 References:
 [1] - http://en.wikipedia.org/wiki/Pidof



use pgrep and pkill instead

their man page says:
pgrep, pkill - look up or signal processes based on name and other
attributes


I use both quite often :-)
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] ps and grep

2008-01-17 Thread pj
Ashish Shukla आशीष शुक्ल [EMAIL PROTECTED] writes:

  Puneet == Puneet Lakhina puneet.lakhina at gmail.com writes:
 Puneet Hi,
 Puneet I have to frequently find the process ids of particular processes
using a
 Puneet combination of ps and grep.
 
 You can try 'pidof'[1], if you're simply interested in find pid of a
 process :)
 
 [snipped]
 
 Puneet But I was wondering if there was a way for me to specify this in
the regular
 Puneet expression for the first grep itself.
 
 Puneet I tried ps -elo pid,args|grep myprocess\\!(grep)
 
 The argument of grep is a regular expression (type 3 language), and
 there is no way you can do this in a type 3 language. Even 'grep' also
 matches 'grep' text when you pass '-v grep' argument to 'grep' command
 line, and then only outputs unmatched lines.

Type 3 and all that: reference: http://en.wikipedia.org/wiki/Regular_language
Makes my eyes glaze over.

And ps output formats confuse me (see the man page if you want to make your
eyes froth and bleed like in a horror movie).

Puneet, with GNU ps what you're trying to do might be done by:

ps -A | grep myprocess

and if you really want to use the elo options (using that makes my GNU ps
barf so I haven't tested it), then maybe stick [] around the first character
in myprocess (ie, make it: [m]yprocess, see if that does the job):

ps -elo pid,args | grep [m]yprocess

I don't think there's a restriction on excluding the inclusion of grep in a
grep based on it being type 3.

YMMV

PJ

PS: pgrep, pkill, pidof (like others have said) may be handier for your needs.



___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] ps and grep

2008-01-17 Thread आशीष शुक्ल Ashish Shukla
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

,--[ On Thu, Jan 17, 2008 at 09:55:33AM +, pj wrote:
| Ashish Shukla आशीष शुक्ल [EMAIL PROTECTED] writes:
| 
|   Puneet == Puneet Lakhina puneet.lakhina at gmail.com writes:
|  Puneet Hi,
|  Puneet I have to frequently find the process ids of particular 
processes
| using a
|  Puneet combination of ps and grep.
|  
|  You can try 'pidof'[1], if you're simply interested in find pid of a
|  process :)
|  
|  [snipped]
|  
|  Puneet But I was wondering if there was a way for me to specify this in
| the regular
|  Puneet expression for the first grep itself.
|  
|  Puneet I tried ps -elo pid,args|grep myprocess\\!(grep)
|  
|  The argument of grep is a regular expression (type 3 language), and
|  there is no way you can do this in a type 3 language. Even 'grep' also
|  matches 'grep' text when you pass '-v grep' argument to 'grep' command
|  line, and then only outputs unmatched lines.

I just noticed, that I'm able to make a FSM for matching that expression, which
implies that I'm wrong. So, I'm sorry.

Thanks
- -- 
Ashish Shukla आशीष शुक्ल  http://wahjava.wordpress.com/
·-- ·-  ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHjzSDHy+EEHYuXnQRAh1WAJ4yABQLt0KlDukd5gGaqFdLQQYfrwCdGhQj
wi0jy/2cJpKullqsav8OB/w=
=C6TR
-END PGP SIGNATURE-

___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


[ilugd] ps and grep

2008-01-16 Thread Puneet Lakhina
Hi,
I have to frequently find the process ids of particular processes using a
combination of ps and grep.
For e.g.

ps -elo pid,args|grep myprocess

But the problem with above is that it gives me a line for the grep process
also.

e.g
213456 /home/puneet/myprocess
219876 grep myprocess

The way I got around this was by using a further pipe

ps -elo pid,args|grep myprocess|grep -v grep

But I was wondering if there was a way for me to specify this in the regular
expression for the first grep itself.

I tried ps -elo pid,args|grep myprocess\\!(grep)

But this does not give any output. I escaped the ! as without the escape it
is considered by the shell as history lookup and it gives me no event found.

-- 
Puneet
http://sahyog.blogspot.com/
Latest Post: Tutorial on SVN setup and usage
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/