简单的苹果脚本在卡塔琳娜下工作,在M1 MBA上的大苏尔下不起作用



我在2013年的MBP上开发了一个脚本(运行良好(,旨在稍后在一系列M1 MBA课程上运行它(在这些课程上根本不起作用(。所以我按照这个方法创建了一个简单的测试脚本。测试脚本在2013年的MBP上运行得非常好,但在M1上也没有任何生命迹象。

#!/usr/bin/osascript
set mySSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'"
display notification mySSID
display alert mySSID

通过chmod+x使其可执行,然后移动到/usr/local/bin/在M1上,我不得不创建bin文件夹,因为/usr/local/下没有

然后在~/Library/LaunchAgents文件夹中创建一个plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.my.checkssid</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/checkSSID</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>10</integer></dict>
</plist>

撰稿人证实了这种方法的有效性。

我也重新启动了M1,但这也不起作用。当我将plist放入~/Library/LaunchAgents并重新启动机器时,当我生成列表并返回"-"时,plist处于活动状态0 com.my.checkssid";。

pluit返回0(无错误(

脚本在M1上从脚本编辑器运行良好

当我将plist放入~/Library/LaunchAgents并重新启动时,plist处于活动状态。我可以通过使用";launchctl卸载<gt">

有没有其他方法可以查看是否调用了脚本?

有线索吗?

谢谢,Pete

我很想知道这是否有效,因为我还没有升级到Big Sur或M1:

#!/usr/bin/osascript
use framework "CoreWLAN"
use scripting additions
get the ssid() of the sharedWiFiClient()'s interface() ¬
of the current application's CWWiFiClient as text
display alert result

最新更新