【问题标题】:Using script to save dynamic network ip address to file?使用脚本将动态网络 IP 地址保存到文件中?
【发布时间】:2013-02-15 11:51:32
【问题描述】:

有没有一种方法可以使用 AppleScript 来检查我的网络 IP 地址?还是替代编码选项?如果 IP 地址已更改,我需要将其保存到文件中,然后将其上传到我的 ftp 服务器,并附上日期和时间戳。我发现这部分只是检查地址。

【问题讨论】:

    标签: ip applescript ip-address appleevents


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      试试:

      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
      

      【讨论】:

        猜你喜欢
        • 2021-11-30
        • 2014-12-09
        • 2022-12-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-02-03
        • 1970-01-01
        • 2020-01-08
        相关资源
        最近更新 更多