Operating System - HP-UX
1833323 Members
2911 Online
110051 Solutions
New Discussion

Re: how do you distinguish between connection types?

 
SOLVED
Go to solution
J. de Haan
Occasional Advisor

how do you distinguish between connection types?

Hi all,

how do you distinguish between connection types? When I connect to a HPUX machine through various means (telnet, dtterm, xterm (local&remote), console) I want to be able to recognize each possible type of connection in /etc/profile to provide the right environment for that type of connection. When I run 'who', I see various types (console, pts/n, dtremote, pts/tx, ttynpn) but I couldn't find documentation on how to test on these, nor what each is, though console obviously is a serial connection.

Thanks for any insight in this.

Sincerely,

Jan de Haan.
4 REPLIES 4
Michael Tully
Honored Contributor

Re: how do you distinguish between connection types?

CDE login = dtremote (.dtprofile)
console = console
telnet = pts/NN (number is in hex)
terminal/modem = tty
Anyone for a Mutiny ?
J. de Haan
Occasional Advisor

Re: how do you distinguish between connection types?

Michael,

you're right in your assignments, but what I really like to know is how to test for them in the various login scripts (/etc/profile, .dtprofile etc.)

Thanks for your fast reply.

Jan.
Bill Thorsteinson
Honored Contributor
Solution

Re: how do you distinguish between connection types?

CDE runs the .dtprofile script
not .profile.

pty -s will set the return code to indicated if you
are on a pseudo-terminal.
If you are you have a dtterm or xterm connection. You
may be able to determine
which by looking at the
$TERM variable.


The command
ps | tail -1 | awk '{print $2}'
will return the device
you are connected on.
You can case on this to determine console, tty, pty.

tty -s will set the return
code to indicate if you
are on a terminal. Use this
to determin if you are running
in batch mode.
Jordan Bean
Honored Contributor

Re: how do you distinguish between connection types?


You could use `lssf $(tty)` to determine the driver used by the device. Please note that tty also works for pty devices, but not the other way around. Take a look at the differences:

From a C3600 running HPUX 11.00 64-bit June 2002:
$ lssf /dev/console /dev/ttyp0 /dev/pts/1 /dev/pts/t1
pseudo driver cn minor 0x000000 /dev/console
pseudo driver ptys minor 0x000000 /dev/ttyp0
pseudo driver pts minor 0x000001 /dev/pts/1
pseudo driver tels minor 0x000034 /dev/pts/t1

We know the console is on the cn device and that other hardwired terminals are ptys devices. We also know that a telnet session grabs a tels device. But it gets tricky with ssh, rlogin, xterm, etc which all use pts devices (and sometimes ptys).

I may comment more later. Until then, I hope you find others' remarks more useful.