1

I'm using Mosh + GNU Screen for most of my remote work. I'm also moving to location during the week (with different IP addresses) and this setup keeps everything running like a charm. There is one wish I have.

I'd like to have the ping speed from the server to the client as a value in the Screen statusbar.

For this I wrote a simple script which does that:

`ping -q -c 1 `who am i | egrep -o "\([^\)]+\)" | egrep -o "[0-9-]+{4}" | sed "s/\-/\./g"` | grep 'rtt min' | cut -d / -f 5 | cut -f 1 -d .

The problem is that when I go to a different location, mosh reconnects, but who am i command doesn't return my real IP anymore.

My question:

Is there a robust command which will return the IP address of the client currently connected using mosh/ssh?


Update:

This seems to work:

ping -q -c 1 `last | grep $USER | grep "still logged in" | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -n 1` | grep 'rtt min' | cut -d / -f 5 | cut -f 1 -d .

Have to test is with more locations.

  • If you found an answer, please fill it to the answer field below, not as an edit to the question. – Jakuje Oct 14 '16 at 18:18
0

I'm found this works:

ping -q -c 1 `last | grep $USER | grep "still logged in" | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -n 1` | grep 'rtt min' | cut -d / -f 5 | cut -f 1 -d .

Last-command shows your 'current' remote ip.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.