Catalina update broke script

New Contributor III

Hi All,

Hoping to get some help here.

One of the minor Catalina update broke my script. It was working until at least 10.15.1

I have an osascript running at login that is triggered by Launch Agents.
The script will display a dialog box.

The launch agent is definitely loaded. I can also see osascript running from Activity Monitor

launchctl list | grep acme 873 0 com.acme.WifiLoginPrompt

but the dialog box doesn't appear. If I unload and reload the plist then the dialog box will appear

launchctl unload ~/Library/LaunchAgents/com.acme.WifiLoginPrompt.plist launchctl load ~/Library/LaunchAgents/com.acme.WifiLoginPrompt.plist

Any suggestions?

Note: this only happens on the very first login attempt, subsequent login will be fine

Thanks for looking!

Launch agent plist below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Script is to prompt user for their password and create a keychain entry


display dialog "Welcome to ACME
Please have your computer login password ready before proceeding to connect to the Wi-Fi." buttons {"OK"} default button "OK" --with icon caution

set t to "" -- all purpose variable holds various types of data
set label to "STAFF WIFI" --e        -- if omitted, service name is used as default label
set KeyKind to "802.1X Password" --e unless new type is "Internet password", then --n
set AcctName to do shell script "echo $LOGNAME"
set Acctpassword to text returned of (display dialog "Please enter your login password to connect to ACME Wi-Fi" default answer "" with hidden answer) -- n
set ServiceName to " WIFI" --n
set AcctComments to "Keychain Added via Apple Script." --e
set WifiPort to do shell script ("networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/,/Ethernet/' | awk 'NR==2' | cut -d ' ' -f 2")

    set t to do shell script "security add-generic-password -a " & QAcctName & " -s " & QServiceName & " -w " & QAcctpassword & " -l " & Qlabel & " -j " & QAcctComments & " -D " & QKeyKind & " -T '/System/Library/SystemConfiguration/EAPOLController.bundle/Contents/Resources/eapolclient' -T '/usr/bin/security' -T '/System/Library/CoreServices/' -T '/System/Applications/System' -T 'group://AirPort'" & " -A " & "-U"
end try

do shell script "`networksetup -setairportpower " & QWifiPort & " off`"

    do shell script "`networksetup -setairportpower " & QWifiPort & " off `"
    do shell script "sleep 2"
    do shell script "`networksetup -setairportpower " & QWifiPort & " on `"
    do shell script "`networksetup -addpreferredwirelessnetworkatindex  " & QWifiPort & " " & Qlabel & " 0 WPA2E`"        
end try

display dialog "All Done! Welcome to the ACME Network" buttons {"OK"} default button "OK"

do shell script "rm -rf ~/Library/LaunchAgents/com.acme.WifiLoginPrompt.plist"

Legendary Contributor III

It might help us help you if you post the script here, or at least the relevant part of it that is getting stuck.
But outside of that, does anything regarding PPPC need to be updated perhaps? What update did you notice broke this? Was it the most recent one?
Lastly, do you have any delay happening in your script before it attempts to display the dialog? I'm just wondering if it's firing too soon after login.

New Contributor III

Thanks! updated with the code.

good idea, I will put delay in the beginning of the code and see what happens

Legendary Contributor III

I wonder if this would be better as a bash or zsh script, and then just call osascript in it as needed for the dialogs. Because most of what you're doing in the script can be done easier in the shell than with straight AppleScript. Just a thought, and I have no idea if it has anything to do with why it stopped working. It's just an observation.

Do post back on your results after putting a slight delay in the script, or perhaps even detecting when the Dock/Finder is fully up and running before actually trying to show any dialogs. That might help.