[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: procps: Regarding FROM field in "w" command



Navdeep Bhatia wrote:
> The "FROM" field in output of "w" command prints the value of the
> remote-host. But the output for this field can contain just 16 characters as
> depicted in the code snippet (taken from w.c, release 3.2.8) below.
> This truncates the value in case FROM field is an IPV6 address or a
> hostname. Is there any specific reason that this is limited to 16 chars
> only?

In the old days node names were limited to eight characters.  (I once
had a hostname "aphrodite" and although 'hostname' would show the full
name 'uname -n' would show it as "aphrodit". :-)

With that in mind limiting to sixteen was probably seen as wide enough
so that columns could be lined up.  If you allow arbitrarily long
hostnames there then the other columns become rather unworkable.
Other than this it seems pretty arbitrary.  The <utmp.h> ut_host field
can be up to 256 (UT_HOSTSIZE) long.

Note: If you try to change the size of fields you will almost
certainly break scripts that have come to rely upon fields being in
specific columns.  So it is not the type of thing that people like to
do lightly.  This is probably the real reason this hasn't changed.  I
think now it should only be expanded under the control of an option
argument that says --full-hostname or some such.

Why do you want to know this information?  Does using the SSH_CLIENT
variable information provide you with what you need to know?

Try these:

  dig -x $(echo $SSH_CLIENT | awk '{print$1}') ptr +short

  host -t ptr $(echo $SSH_CLIENT | awk '{print$1}') | awk '{print$NF}'

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: