which host
From: Werner Winter (werner.winter_at_asamnet.de)
Date: 10/31/03
- Next message: Stuart Moore: "Re: Aps and Linux"
- Previous message: Steve Grazzini: "Re: How to tell what modules are installed?"
- Next in thread: David Efflandt: "Re: which host"
- Reply: David Efflandt: "Re: which host"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 31 Oct 2003 16:28:21 +0100
Hello,
I've setup a linux terminal server. Now I want to know, which user is logged
in on which host . So I wrote a perl-script named "which_host"
# which user
$uid=$<;
$username=(getpwuid)$uid))[0];
$username = $1;
#which host
@last= `/usr/bin/last -n 1 -a $username`;
# line 18
$host= (split (/\s+/, $last[0]))[9];
The last two lines cause an error: Use of uninitialized value in string eq
at /usr/local/bin/which_host line 18
The problem is, that "last" shows only 8 columns, no host in column 9 is
shown. If I change the line
@last= `/usr/bin/last -n 1 -a $username`;
to
@last= `/usr/bin/last -n 3 -a $username`;
then I get 3 lines and in the third line the host is shown in column 9.
What can I do?
cu
Werner
- Next message: Stuart Moore: "Re: Aps and Linux"
- Previous message: Steve Grazzini: "Re: How to tell what modules are installed?"
- Next in thread: David Efflandt: "Re: which host"
- Reply: David Efflandt: "Re: which host"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|