Re: "pidof" on a process (which was ran by passing arguments from the command line)
From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 07/04/05
- Next message: Alan Connor: "Re: need newline help"
- Previous message: Janis Papanagnou: "Re: tar everything except *.A and xx.B"
- In reply to: amirbin_at_hotmail.com: ""pidof" on a process (which was ran by passing arguments from the command line)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 3 Jul 2005 18:23:37 -0400
On 2005-07-03, amirbin@hotmail.com wrote:
> Hello,
>
> This question may be relevant to running "pidof" generally on processes
> which were run by passing an argument in the command line;
> To me it occurred with python.
>
> I am running a python script of xen.
>
> I want to be able to get the pid of that process by running "pidof".
>
> The command line for running the script is
> /xend start
> (but in fact it runs "python ./xend start" because the first line in
> "xend"
> script is "#!/usr/bin/env python".)
>
> ("python ./xend start"" is also what we get (among other processes)
> from
> ps -aux |grep python for that specific process I am talkng about).
>
>
> I want to be able to get the pid of that process by runnning "pidof".
>
>
> pidof "python ./xend start" gives nothing (in Bash and in Tcshell).
>
> pidof "python" gives 4 processes (one of them is the requested one).
>
> Moreover:
> 2502 is the process id of the wanted process.
> cat /proc/2502/cmdline
> gives:
> python./xendstart
>
>
> but trying pidof "python./xendstart" (also with one apostrphe or none
> at all)
> gave nothing.
>
>
> Also "pidof -x xend" does not help : it returns an empty string.
>
> Any idea?
pidof obviously does not do what you want, so you need to use a
different command (or combine pidof with other commands).
What wrong with:
set -- $( ps ax | grep 'python.*\./xend' )
xend_pid=$1
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
==================================================================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>
- Next message: Alan Connor: "Re: need newline help"
- Previous message: Janis Papanagnou: "Re: tar everything except *.A and xx.B"
- In reply to: amirbin_at_hotmail.com: ""pidof" on a process (which was ran by passing arguments from the command line)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|