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.