Operating System - HP-UX
1827293 Members
1722 Online
109717 Solutions
New Discussion

Re: /dev/ttyXX entries and mywho

 
Michael Kelly_5
Valued Contributor

/dev/ttyXX entries and mywho

When I run /usr/contrib/bin/mywho on one of my HP-UX 11i systems, it will regularly fail with an error like:

stat(/dev/ttyw2) failed: No such file or directory

If I create /dev/ttyw2 as a (hard) link to /dev/pty/ttyw2 then mywho will get past this point and may run to completion or fail with another stat error.
If I fix all the missing links then it will be OK for a while.

I also notice that mywho reports "0.0.0.0" as the IP address for all ttyXX entries but the IP addresses for all pts/ entries are OK.

We use mywho to figure out how to set the DISPLAY variable during login so this is causing a bit of a problem.

I installed patch PHNE_24829 and it made no difference.
What process(es) is/are responsible for managing the /dev/ttyXX entries?

Any ideas?

Regards,
Michael.
The nice thing about computers is that they do exactly what you tell them. The problem with computers is that they do EXACTLY what you tell them.
5 REPLIES 5
Mark Grant
Honored Contributor

Re: /dev/ttyXX entries and mywho

I have never heard of "mywho" and it doesn't seem to exist on any of our machines. What does it do? It sounds like it might be someones script. If so, this might be a bit hard to debug without seeing it.

On the other hand, why do you need this to set your DISPLAY variable on login. This should all be handled by whatever xdmcp login app you are using. If you mean you want to telnet to a random box and have the ip address you logged in from translated to a display variable, do something like this

expr "`who -R | grep $LOGNAME`" : '.*(\(.*\))'
Never preceed any demonstration with anything more predictive than "watch this"
Robert-Jan Goossens
Honored Contributor

Re: /dev/ttyXX entries and mywho

Hi Michael,

I don't think there is a mywho command.

How about using something like

# -- Do trick to set the display in case of remote login
HOST=`who am i -R |awk '{print $NF}' | sed "s/(\(.*\))/\1/"`
if [ "$HOST" != "" ] && [ "$HOST" != ":0" ] && [ "$HOST" != ":0.0" ];
then
if [ "$HOST" = `who am i -R |awk '{print $NF}' | sed "s/(\(.*\))/\1/"` ]
then
HOST=$HOST:0.0
fi
echo " +--<<"
echo " | Remote login detected, setting DISPLAY to $HOST"
echo " +-->>"
DISPLAY=$HOST
export DISPLAY

HTH,
Robert-Jan
Bill Hassell
Honored Contributor

Re: /dev/ttyXX entries and mywho

To answer the question about /dev/pty files, the insf command can add more pty device files. However, SAM works better in that it will adjust the npty kernel parameter as well as fill in missing pty devices.

However, there is no need to use mywho...just replace the mywho code with:

DISPLAYHOST=$(/usr/bin/who -muR | awk '{print $NF}')
DISPLAY="${DISPLAYHOST%%:0.0}:0.0"

This assumes that the user is telnet'ing direct to the server and going thtough several intermediate boxes.


Bill Hassell, sysadmin
Michael Kelly_5
Valued Contributor

Re: /dev/ttyXX entries and mywho

I mentioned the mywho program as it is in the contrib directory and I thought that someone would recognise it. It basically does the same job as 'who -R' (the principal differences being that mywho prints IP addresses instead of FQDNs and it also prints the PID no.), Perhaps it was written before who had a -R option? I don't know. It was here before me and we have two other 11i systems where this particular 'problem' doesn't occur.
It seems to me that the basic problem is that these /dev/ttyXX entries keep disappearing (or are not being recreated) and I don't know why. Perhaps this behaviour is perfectly normal and whoever wrote mywho made assumptions s/he had no valid reason to make.
If I can't solve the mystery of the disappearing tty entries it looks like `who -R` might be a viable workaround.
Thanks for the assistance so far.
The nice thing about computers is that they do exactly what you tell them. The problem with computers is that they do EXACTLY what you tell them.
Bill Hassell
Honored Contributor

Re: /dev/ttyXX entries and mywho

The disappearing pty devices is a concern. The reason is that although the device files have 666 permissions, they cannot be removed by any user except root unless the permissions for /dev is 777 in which case you have an security emergency! Look at the man page for pty(7) to see how the names are generated (man 7 pty, down at the bottom of the page).


Bill Hassell, sysadmin