获取本机的公网IP,用于在conky中显示

#!/bin/bash
for i in `seq 5`
do
ip=`curl "http://ifconfig.me/ip"`     
if [ ${#ip} -le 15 -a ${#ip} -ge 7 ];then
    public_ip=$ip
    break
else
    public_ip="no connection"
fi
done
echo $public_ip
echo $public_ip > /tmp/public_ip

你可能感兴趣的:(获取本机的公网IP,用于在conky中显示)