我为我的大部分远程工作使用Mosh + GNU屏幕。 我也在一周内(不同的IP地址)移动到位置,这个设置保持一切运行像一个魅力。 我有一个愿望。
我想从服务器到客户端的ping速度作为屏幕状态栏中的值。
为此我写了一个简单的脚本来做到这一点:
`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 .
问题是,当我去一个不同的位置,莫什重新连接,但who am i命令不会返回我的真实IP了。
我的问题:
有一个强大的命令,将返回当前使用mosh / ssh连接的客户端的IP地址?
更新:
这似乎工作:
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 .
必须testing更多的位置。
我发现这个作品:
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 last | grep $USER | grep "still logged in" | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -n 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'| 切-d / -f 5 | cut -f 1 -d。
Last-command显示你当前的远程IP。