Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

example required for ' who -l '

Status
Not open for further replies.

latch

Programmer
Jun 26, 2001
89
0
0
DE
Hi
Can someone give an example of how

who -l

can be used?

regards
CM


"Brahmaiva satyam"
-Adi Shankara (788-820 AD)
 
Is this a homework assignment ?

who -l shows who is logged in. What else is there ?

::) if this sounds harsh, it is not meant to be.

Bill.
 
According to the man page, who -l:

-l This option lists those lines on which the system is
waiting for someone to login. The name field is LOGIN
in such cases. Other fields are the same as for user
entries except that the state field does not exist.

Hope this helps.
 
ifincham,
If I have interpreted you correctly....if a remote user is connected to my box..the 'who -l' command tries to resolve the IP of the remote user is connected from ..right?


regards
CM



PS:
no this is not a homework assignment...this is a genuine enquiry from someone trying to learn SysAdmin. "Brahmaiva satyam"
-Adi Shankara (788-820 AD)
 
Hi,

Yes, it actually tries to resolve all the 'hostnames' found using the standard resolver functions - could be /etc/hosts, dns, etc.

If you really want to know look at the source code (who.c in ftp://ftp.gnu.org/pub/gnu/sh-utils/sh-utils-2.0.tar.gz) .

That calls canon-host.c which in turn uses the system calls gethostbyname() and then gethostbyaddr() - i.e. :

if (addr && strcmp (he->h_name, addr) == 0)
{
/* gethostbyname has returned a string representation of the IP
address, for example, "127.0.0.1". So now, look up the host
name via the address. Although it may seem reasonable to look
up the host name via the address, we must not pass `he->h_addr'
directly to gethostbyaddr because on some systems he->h_addr
is located in a static library buffer that is reused in the
gethostbyaddr call. Make a copy and use that instead. */
char *h_addr_copy = strdup (he->h_addr);
if (h_addr_copy == NULL)
he = NULL;
else
{
he = gethostbyaddr (h_addr_copy, he->h_length, he->h_addrtype);
free (h_addr_copy);
}
}


Also, interesting that on the Digital Unix box i'm using at the moment the -l parameter is the same as KenCunningham posted - i.e. this is probably unique to the gnu/linux version of 'who'.

Regards
 
Thanks for the help ifincham , all
"Brahmaiva satyam"
-Adi Shankara (788-820 AD)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top