andyc@bucky.intel.com (Andy Crump) (05/31/91)
>>>>> On 31 May 91 12:06:30 GMT, gilette@trinidad.inria.fr (Serge Gilette) said:
Serge> i was wondering how a script shell can tell the process id of the
Serge> shell it's attached to (in order to being able to kill it).
Try the variable $$.
--
-- Andy Crump
...!tektronix!reed!littlei!andyc | andyc@littlei.intel.com
...!uunet!littlei!andyc | andyc@littlei.uu.net
Disclaimer: Any opinions expressed here are my own and
not representive of Intel Corportation.
gilette@trinidad.inria.fr (Serge Gilette) (05/31/91)
i was wondering how a script shell can tell the process id of the shell it's attached to (in order to being able to kill it). Gilette - Serge
rearl@watnxt3.ucr.edu (Robert Earl) (05/31/91)
In article <11563@mirsa.inria.fr> gilette@trinidad.inria.fr (Serge Gilette) writes: | i was wondering how a script shell can tell the process id of the | shell it's attached to (in order to being able to kill it). | | Gilette - Serge Attached to? You mean the current process? It's in "$$"; as in kill -9 $$ There's no way to get the parent process from conventional shells. But, if you just want to kill the parent... exec perl -e 'kill 9, getppid' :-) -- ______________________________________________________________________ \ robert earl / "Love is a many splintered thing" rearl@watnxt3.ucr.edu \ --Sisters of Mercy rearl@gnu.ai.mit.edu /
cstaqaf@warwick.ac.uk (Richard Broadley) (06/02/91)
Could someone tell me if there is something I can add to my .cshrc or my .tcshrc which will be able to find out the hostname/username of where a rsh is coming from? Is it called the peername? Richard -- +--------------------------------------------------------------------------+ | Uk (Janet) address: cstaqaf@uk.ac.warwick.cu | | Full world address: cstaqaf%cu.warwick.ac.uk@nsfnet-relay.ac.uk | +--------------------------------------------------------------------------+
mouse@thunder.mcrcim.mcgill.edu (der Mouse) (06/06/91)
In article <&~2_YC$@warwick.ac.uk>, cstaqaf@warwick.ac.uk (Richard Broadley) writes: > Could someone tell me if there is something I can add to my .cshrc or > my .tcshrc which will be able to find out the hostname/username of > where a rsh is coming from? An rsh? You'll need to write a program. An rlogin you can make a reasonable stab at by looking at the output of programs like who. > Is it called the peername? See, you didn't need to ask; you knew the answer already! Yes, what you are looking for is termed the peer address in the socket documentation, and is obtained with the getpeername() syscall. Of course, that gets you only the machine's address. The machine's name would be obtained by applying gethostbyaddr() to the address; the remote username generally isn't available by the time your .cshrc is being read. This assumes your rshd leaves the stdin/stdout/stderr of the remote command connected directly to the pipe. To determine this, try it; if it's not so, getpeername() should fail with errno set to ENOTSOCK. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu