使用脚本将动态网络ip地址保存到文件?

使用脚本将动态网络ip地址保存到文件?,ip,applescript,ip-address,appleevents,Ip,Applescript,Ip Address,Appleevents,有没有办法使用AppleScript检查我的网络ip地址?还是另一种编码方式?如果ip地址已更改,我需要将其保存到文件中,然后将其上载到带有日期和时间戳的ftp服务器。我已经找到了这部分内容,只是检查了地址。试试: set filePath to POSIX path of ((path to desktop as text) & "myIp.txt") set myIp to do shell script "curl checkip.dyndns.org | grep -Eo [0-

有没有办法使用AppleScript检查我的网络ip地址?还是另一种编码方式?如果ip地址已更改,我需要将其保存到文件中,然后将其上载到带有日期和时间戳的ftp服务器。我已经找到了这部分内容,只是检查了地址。

试试:

set filePath to POSIX path of ((path to desktop as text) & "myIp.txt")
set myIp to do shell script "curl checkip.dyndns.org | grep -Eo [0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+ > " & quoted form of filePath

ifconfig.me只返回一个纯文本公共IP:

do shell script "curl ifconfig.me > ip.txt"