Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Applescript ip地址更改=启动认证应用程序_Applescript - Fatal编程技术网

Applescript ip地址更改=启动认证应用程序

Applescript ip地址更改=启动认证应用程序,applescript,Applescript,我使用mac电脑,使用脚本编辑器或automator,我希望在连接到特定ip地址时自动运行应用程序。我一直在尝试使用以下脚本编辑器: if IP address is changed to "192.168.2.102" or "192.168.2.103" tell application "app" activate end tell 但它仍然需要我付出更多。。。 我可能还不太接近,但我对此毫无经验。您可以在空闲时使用使脚本在后台运行。以下面的例子为例: global ipValue

我使用mac电脑,使用脚本编辑器或automator,我希望在连接到特定ip地址时自动运行应用程序。我一直在尝试使用以下脚本编辑器:

if IP address is changed to "192.168.2.102" or "192.168.2.103" 

tell application "app" activate end tell
但它仍然需要我付出更多。。。
我可能还不太接近,但我对此毫无经验。

您可以在空闲时使用
使脚本在后台运行。以下面的例子为例:

global ipValue

on idle
    set newIpValue to do shell script "curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g'" as string

    if not (newIpValue = ipValue) then
        -- perform your action
    end if

    return 10 -- time in seconds to perform checking
end idle
全局ipValue
闲置
将newIpValue设置为执行shell脚本“curl-s”http://checkip.dyndns.org |sed's/[a-zA-Z/:]///g'”作为字符串
如果不是(newIpValue=ipValue),则
--执行你的行动
如果结束
返回10——执行检查的时间(秒)
结束空闲
另外,在将脚本保存为应用程序时,必须在AppleScript的“保存”对话框中标记“保持打开状态”


我不确定您想要哪个IP,但这个示例获取的是您的web IP。

嘿,非常感谢您的回答,我希望它能够激活两个IP地址的应用程序,所以我是否可以将IP地址放在“(newIpValue=ipValue)”中,并指定要运行的应用程序?使用:
如果newIpValue=“192.168.2.102”或newIpValue=“192.168.2.103”然后
。但是新的IPValue正在设置来自internet的IP。我猜您正在尝试检查本地IP。