[comp.unix.shell] Killing process w/o number

nichols@en.ecn.purdue.edu (Scott P Nichols) (04/19/91)

Could someone tell me how I could set up an alias to kill a process
using something other than its number?  Say, for example something like:

alias	noss	???????????

What do I put in the ?????????? so that it kills the sysline in my
processes as follows:  (even if the number is different?)

  PID TT STAT TIME COMMAND
19500 v3 S    0:02 -csh (csh)
19731 v3 S    0:00 sysline -Dhr +15

Thanks for the info.

Scott

-- 
O-        /\
|\     /\/vv\                  _Insight from Oregon...Scott P. Nichols
      /vv\   \        	      /                     (nichols@en.ecn.purdue.edu)
_____/    \   ~~~~~~~~~~~~~~~~                         (nichols@techbook.com)

jgabriel@mtecv2.mty.itesm.mx (Juan Gabriel Ruiz Pinto) (04/19/91)

nichols@en.ecn.purdue.edu (Scott P Nichols) writes:

>  PID TT STAT TIME COMMAND
>19500 v3 S    0:02 -csh (csh)
>19731 v3 S    0:00 sysline -Dhr +15

   You could use the next c-shell script to do that..

#!/bin/csh
#
set line = `ps -ax | grep -v grep | grep sysline`

if $status == 0 then
   kill -9 $line[1]
-- 
Juan Gabriel Ruiz Pinto                   Internet:
Ing. Sistemas Electronicos                jgabriel@mtecv2.mty.itesm.mx
I.T.E.S.M. Campus Monterrey

cudcv@warwick.ac.uk (Rob McMahon) (04/24/91)

In article <3209@mtecv2.mty.itesm.mx> jgabriel@mtecv2.mty.itesm.mx (Juan
Gabriel Ruiz Pinto) writes: 
>set line = `ps -ax | grep -v grep | grep sysline`

I've always wondered why people always do this rather than

	ps axc | grep sysline

... 

Rob
-- 
UUCP:   ...!mcsun!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             INET:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

jik@athena.mit.edu (Jonathan I. Kamens) (04/25/91)

In article <+-A_7A#@warwick.ac.uk>, cudcv@warwick.ac.uk (Rob McMahon) writes:
|> I've always wondered why people always do this rather than
|> 
|> 	ps axc | grep sysline

Because the 'c' option to grep isn't universally supported.  On an A/UX (SysV
based) system:

% ps axc
usage: ps [ -edalf ] [ -c corefile ] [ -s swapdev ] [ -n namelist ] [ -t tlist ]
        [ -p plist ] [ -u ulist ] [ -g glist ]

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710

moliver@shadow.pyramid.com (Mike Oliver) (04/26/91)

In article <1991Apr24.214750.24522@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes:
>In article <+-A_7A#@warwick.ac.uk>, cudcv@warwick.ac.uk (Rob McMahon) writes:
>|> I've always wondered why people always do this rather than
>|> 
>|> 	ps axc | grep sysline
>
>Because the 'c' option to grep isn't universally supported.

That's what I said in e-mail, but Rob pointed out that the original use
of `ps -ax' probably means that this is a BSD system which will also
understand the `-c' option.

The giveaway is that the AT&T `ps' doesn't support `-x'.  (Of course,
it's always possible that there's some weird variant of a `ps' out
there that accepts `-ax' and doesn't accept `-axc'.  I don't know of
one.)

As an aside - if you're on an AT&T system, `ps -e' produces something
that looks a lot like the Berkeley `ps -axc'.

Cheers, Mike.

moliver@pyramid.com
{allegra,decwrl,hplabs,munnari,sun,utai,uunet}!pyramid!moliver

nichols@en.ecn.purdue.edu (Scott P Nichols) (04/26/91)

In article <153231@pyramid.pyramid.com> moliver@shadow.pyramid.com (Mike Oliver) writes:
>In article <1991Apr24.214750.24522@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes:
>>In article <+-A_7A#@warwick.ac.uk>, cudcv@warwick.ac.uk (Rob McMahon) writes:
>>|> I've always wondered why people always do this rather than
>>|> 
>>|> 	ps axc | grep sysline
>>
>>Because the 'c' option to grep isn't universally supported.
>
>That's what I said in e-mail, but Rob pointed out that the original use
>of `ps -ax' probably means that this is a BSD system which will also
>understand the `-c' option.
>
>The giveaway is that the AT&T `ps' doesn't support `-x'.  (Of course,
>it's always possible that there's some weird variant of a `ps' out
>there that accepts `-ax' and doesn't accept `-axc'.  I don't know of
>one.)
>
>As an aside - if you're on an AT&T system, `ps -e' produces something
>that looks a lot like the Berkeley `ps -axc'.
>
>Cheers, Mike.

As the original asker of the question, I will confirm that ps -x did
what I wanted.  If I type ps -ax, I get the processes for all users,
not just me.  I don't think the -a is necessary.

Thanks for all of your advice.

Scott
-- 
O-        /\
|\     /\/vv\                  _Insight from Oregon...Scott P. Nichols
      /vv\   \        	      /                     (nichols@en.ecn.purdue.edu)
_____/    \   ~~~~~~~~~~~~~~~~                         (nichols@techbook.com)

alan@ukpoit.co.uk (Alan Barclay) (05/02/91)

In article <+-A_7A#@warwick.ac.uk> cudcv@warwick.ac.uk (Rob McMahon) writes:
>In article <3209@mtecv2.mty.itesm.mx> jgabriel@mtecv2.mty.itesm.mx (Juan
>Gabriel Ruiz Pinto) writes: 
>>set line = `ps -ax | grep -v grep | grep sysline`
>
>I've always wondered why people always do this rather than
>
>	ps axc | grep sysline

the command "ps -ef | grep -v grep | grep listen" gives (all bar
command line delted)

/usr/etc/tcplisten ftp finger rlogin remsh rexec telnet 
listen -n tcp -l 0002040190570101 

while "ps -ef | grep listen" gives (all bar command line delted)

/usr/etc/tcplisten ftp finger rlogin remsh rexec telnet 
listen -n tcp -l 0002040190570101 
sh -c ps -ef | grep listen 
grep listen 

now obviously the shell to run the grep (*) and the grep itself have
now died so if you are wanting just the running commands or something
similar you need to remove the greps. In otherwords sometimes you need
it.
-- 
  Alan Barclay
  iT                                |        E-mail : alan@ukpoit.uucp
  Barker Lane                       |        BANG-STYLE : .....!ukc!ukpoit!alan
  CHESTERFIELD S40 1DY              |        VOICE : +44 246 214241