[Techtalk] Shell script to send user defined signal to a process

Kai MacTane kmactane at GothPunk.com
Thu Sep 18 21:03:46 EST 2003


At 9/18/03 07:09 PM , ruchika khera wrote:

>    I want my shell script to send a user defined signal to a process. I
>    know that using pidof <processname> I can get the pid of the process
>    and using kill <sig #> <pid> i can send the signal to the process
>    whose id is eq to <pid>. How can I do this in a shell script.
>
>    The foll does not work -
>    #!/bin/sh
>    PD=pidof test
>    kill 41 $PD

I assume that last line is meant to read: "kill $1 $PD"? Assuming that to 
be the case, your problem is that you're setting $PD to 'pidof' and then 
running the test builtin. To set PD to the output of the command "pidof 
test", you have to enclose it in back-ticks:

PD=`pidof test`

                                                 --Kai MacTane
----------------------------------------------------------------------
"When the clouds pull apart/And the Moon changes phases,
  In the quiet, secret places/Are you there? Are you there?"
                                                 --Concrete Blonde,
                                                  "Darkening of the
                                                   Light"



More information about the Techtalk mailing list