LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Identifying telnet connections?

[ILUG] Identifying telnet connections?

Kevin Dobey kevin.dobey at trintech.com
Thu Jun 3 11:49:19 IST 1999


Relating to your awk problem...

if you do something like 
who | awk '/'$USER'/' {print $6} ' 
the $USER gets expanded into the awk command. 
	(you can muck this approach into your requirement) 

Even better - 
 export Myip=`who | awk '/'$USER'/ {print substr(substr ($6,2),1,length($6)
- 2 ) }' | tail -1`

That will strip out the braces either side of the IP address aswell 
feel free to add a ":0" string to the end as you like !!

I have a DHCP'ed address here so it can change on me so on my AIX log on I
have a line that does something similar...

export MYIP=`who -q | grep $LOGNAME | head -1 | cut -f2 -d "(" | cut -f1
-d")"` 
export DISPLAY=$MYIP:0

I didn't know about awk at the time.

However this has some core problems !!
If I start at "mypcclient" and go to "unixbox1" and go to "unixbox2" then my
display will be set to "unixbox1:0" by this script. 

Of course that's no good at all. 
Also if the ip address is in the name form and is long who cuts it short it
short
perhaps if I used last (which I learned about today - thank you ILUG) it
would be better. 

Of course "who am i" or "who -m" (thanks again ILUG) would be better. 
But thats academic. 

-----Original Message-----
From: Paul Jakma [mailto:Paul.Jakma at Digital.com]
Sent: 03 June 1999 10:20
To: 'Tony_Melia at Dell.com'
Cc: 'ilug at linux.ie'
Subject: RE: [ILUG] Identifying telnet connections?


ok.. i misunderstood, sorry.

maybe something along the lines of:

export DISPLAY=`last -a -n 1 $USER | awk '/mydomain.ie/ { print $10 }'`

would do the trick.

it works for me, the reason for using the domain name is cause i can't see
how to get the username into the awk pattern, eg:

awk '/$USER/ { print $10}' doesn't work cause the awk command string isn't
parsed by bash.

and awk '/ENVIRON["USER"] {print $10 }' doesn't do it either.

any awk/perl hackers out there?

hth,

paul.

> ----------
> From: 	Tony_Melia at Dell.com[SMTP:Tony_Melia at Dell.com]
> Sent: 	03 June 1999 09:27
> To: 	Paul Jakma
> Subject: 	RE: [ILUG] Identifying telnet connections?
> 
> windows....crt...also I tried standard windows nT telnet.
> I just tried linux>linux telner (both RH6) and it says unable to open
> display %s.  so I presume it expects the %s paramater to the the
> variable....???
> 

-- 
Irish Linux Users' Group: ilug at linux.ie
http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
List maintainer: listmaster at linux.ie




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell