I’m using an old Mac (Big Sur) and Script Editor v2.11.
I am not turning my script into an app, I am just letting it run in the background in script editor.
While running my main script on my Mac, I want to scan for the IP of my iPhone in the WIFI network. Both the Mac and the iPhone are in the same wifi-network.
If the iPhone is there, I want to do X, if it is not logged into the wifi, I do Y.
I noticed that I - in general, so even in a new fresh empty script - get different results scanning for the iPhone depending on if I execute from script editor or from a normal terminal window. Running ping in terminal will find the local iPhone IP, but doing it from inside script editor via do shell script will not.
To troubleshoot, I downloaded nmap.
nmap -sn “local IP of Mac”/24 executed from terminal can “see” my iPhone without issue (and the other connected devices).
Running any of the following 4 options in Script Editor, will not find the iPhone (but the other connected devices it will find - for the last 3 options).
I don’t understand why a normal terminal window will find it, but when I spawn a terminal window from Script Editor, the result changes.
do shell script ("ping -t 15 -q [local IP of iPhone]")
do shell script ("usr/local/bin/nmap -sn [local IP of Mac]/24")
do shell script "eval $(usr/libexec/path_helper -s);" & "nmap -sn [local IP of Mac]/24"
tell application "Terminal"
do script ("nmap -sn [local IP of Mac]/24")
end tell
I did check the mac-firewall and did not see Script Editor listed in there. To troubleshoot, I added Script Editor and set it to allow incoming connections, but it made no difference.
Thank you for reading!