How to find the IP of the terminal who is currently logged in?

I was able to write a script returning the IP address of the logged in remote user. It goes like this:

nslookup `pinky | sed -n '2,2p' | awk '{ print $5}'` | tail -n2 | grep Address |  awk '{ print $2}'

However, due to the heavy parsing involved, I can't be certain that it would function flawlessly under all conditions.

Is there a better approach?



ip="${SSH_CLIENT/ */}"

it's shorter.

On the other hand, I'm not sure what exactly did you mean by 2,2p. Which remote user do you want? The first on the list?

Need Your Help

How to set lower bound for random values in SQL

mysql sql random generator

I want to insert multiple random values into one of my columns. However I don't want small values like 1.5 and so on. How do I set the lower bound for random numbers?

What is the correct way to dealloc a lock in objective-c

objective-c synchronization locking dealloc

I have created an NSObject, for the sole purpose of locking.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.