[net.unix] Can I read someone else's environment?

silvert@dalcs.UUCP (Bill Silvert) (06/18/86)

I just kludged together a message system that puts a short note on the
alert line (#25) of someone else's terminal.  This is preferable to
write(1) for us, since we are usually editing files when a message
scrambles the screen.  For hard-wired terminals I can get the terminal
type from /etc/ttytypes, but is there any way I can read the terminal
type for a dial-up line so that I know what escape codes to send?

jrw@hropus.UUCP (Jim Webb) (06/19/86)

> I just kludged together a message system that puts a short note on the
> alert line (#25) of someone else's terminal.  This is preferable to
> write(1) for us, since we are usually editing files when a message
> scrambles the screen.  For hard-wired terminals I can get the terminal
> type from /etc/ttytypes, but is there any way I can read the terminal
> type for a dial-up line so that I know what escape codes to send?

If you have a nice system administrator, you could hack up the ps command
to look at the environment (it is passed right after the arguments to the
command) of the person's commands.  It should be noted that the person
needs to be running something other than his/her shell, as it usually
has just HOME, PATH, and SHELL set in it, everything else, namely TERM,
is set by the shell and is not part of its "environ" environment, but
rather these are stored in its data segment and passed to all children.

Just look at the code for the -f option and the rest should be quite
trivial.
-- 
Jim Webb                                        ihnp4!houxm!hropus!jrw

avolio@decuac.DEC.COM (Frederick M. Avolio) (06/21/86)

In article <512@hropus.UUCP>, jrw@hropus.UUCP (Jim Webb) writes:
> > type from /etc/ttytypes, but is there any way I can read the terminal
> > type for a dial-up line so that I know what escape codes to send?
> If you have a nice system administrator, you could hack up the ps command
> to look at the environment (it is passed right after the arguments to the

A few months ago someone posted sps to net.sources.  I don't have it
anymore.  But if you could get it, you could pull out the code therein
to display environment variables along with everything else.  (This
for people who don't have access to sources.)
-- 
Fred @ DEC Ultrix Applications Center
INET: avolio@decuac.DEC.COM				* Fight the Fight *
UUCP: {decvax,seismo,cbosgd}!decuac!avolio	       * Rescue the Unborn *

mouse@mcgill-vision.UUCP (der Mouse) (06/26/86)

>> [wants to read another process' environment]
> If you have a nice system administrator, you could hack up the ps command
> to look at the environment [...].
>
> Just look at the code for the -f option and the rest should be quite
> trivial.

     Or,  depending on  your  system, use  `ps e'.   I assume the second
poster above was  on a USG system, our (4.2bsd)  ps has no f  option and
*does* have the  e option, which  is defined to print the environment of
the command.

     There is a problem with this approach; if the environment is really
big (more than about 1K for our system), ps cannot read it all.  I spent
some time grubbing about in  the sources for ps and the  kernel and this
would  NOT be easy to  fix (or if it would, someone please tell me how -
4.2bsd VAX).
-- 
					der Mouse

USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     philabs!micomvax!musocs!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
        mcvax!seismo!cmcl2!philabs!micomvax!musocs!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa

"Come with me a few minutes, mortal, and we shall talk."