Skip to main content
Solved

Cocoa Dialogue Issues


Forum|alt.badge.img+10
  • Valued Contributor
  • 224 replies

Will cocoa dialogue run as the root user? I'm currently getting the following error when running as a policy:

Script result: 2017-09-06 14:11:11.575 cocoaDialog[86217:1180463] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data<br/>2017-09-06 14:11:11.576 cocoaDialog[86217:1180463] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data<br/>2017-09-06 14:11:11.576 cocoaDialog[86217:1180463] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data<br/>2017-09-06 14:11:11.578 cocoaDialog[86217:1180463] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data<br/>2017-09-06 14:11:11.926 cocoaDialog[86217:1180463] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data<br/>2017-09-06 14:11:11.926 cocoaDialog[86217:1180463] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data<br/>

However everything works ok if I run it on my machine.

#!/bin/bash

lastBootTime=$(sysctl kern.boottime | awk -F'[ |,]' '{print $5}')   ## Raw unix time in seconds of last boot up
currentTime=$(date +"%s")                                           ## Current time in unix seconds
upTimeRaw=$((currentTime-lastBootTime))                             ## Calculation of difference between boot and current time ( total time up in seconds )
upTimeMin=$((upTimeRaw/60))                                         ## Calculation of uptime in minutes total ( uptime in seconds div by 60 )
upTimeHours=$((upTimeMin/60))                                       ## Calculation of uptime in hours total ( uptime in minutes div by 60 )
upTimeDays=$((upTimeHours/24))                                      ## Calculation of uptime in whole days total ( uptime in hours  div by 24 )
minusMinutes=$((((upTimeDays*24))*60))                              ## Total minutes up in whole days ( [uptime in whole days x 24] x 60 minutes )
remainingMin=$((upTimeMin-minusMinutes))                            ## Calculation of remaining minutes to subtract
remainingHrs=$((remainingMin/60))                                   ## Calculation of remaining hours to subtract
minusHours=$((upTimeHours-remainingHrs))

## Figure out minutes value for uptime display
total1=$((upTimeDays*24*60))
total2=$((remainingHrs*60))
minusMinutes2=$((total1+total2))
remainingMinFin=$((upTimeMin-minusMinutes2))

UptimeThreshold1alt=$((UptimeThreshold1-1))
UptimeThreshold2alt=$((UptimeThreshold2-1))

if [ "$upTimeDays" == "1" ]; then
    daysText="Day"
else
    daysText="Days"
fi

if [ "$remainingHrs" == "1" ]; then
    hrsText="Hour"
else
    hrsText="Hours"
fi

if [ "$remainingMinFin" == "1" ]; then
    minsText="Minute"
else
    minsText="Minutes"
fi




CD="/Users/Shared/CocoaDialog.app/Contents/MacOS/cocoaDialog"
### Simple example, one bubble

if [ -e $CD ]
    then

$CD bubble --debug --title "Uptime Warning" --text "You haven't restarted in $upTimeDays $daysText, $remainingHrs $hrsText, $remainingMinFin $minsText Please Restart Soon!" --x-placement center --timeout 30 --background-top "FF0505" --background-bottom "FF0505" --icon "hazard"

else
exit 1
fi
exit 0

Best answer by nkalister

those messages in the logs are common with CD and can be ignored. I use CD extensively, and we see those messages in the policy logs all the time, but everything works.
Test to be sure, but it should be fine.

View original
Did this topic help you find an answer to your question?

5 replies

Forum|alt.badge.img+19
  • Contributor
  • 437 replies
  • Answer
  • September 6, 2017

those messages in the logs are common with CD and can be ignored. I use CD extensively, and we see those messages in the policy logs all the time, but everything works.
Test to be sure, but it should be fine.


boberito
Forum|alt.badge.img+22
  • Jamf Heroes
  • 449 replies
  • September 7, 2017

You may want to start using other methods such as jamfhelper or even AppleScript (https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/DisplayDialogsandAlerts.html)

CD apparently will no longer work in High Sierra is what I read.


Forum|alt.badge.img+19
  • Contributor
  • 437 replies
  • September 7, 2017

CD works just fine in High Sierra.
CD is 32 bit, though, so it could stop working in the OS after High Sierra if Apple drops support for 32 bit applications.
Of course, the source code for CD is on GitHub, so there's nothing stopping anyone from making it 64-bit!


Forum|alt.badge.img+10
  • Author
  • Valued Contributor
  • 224 replies
  • September 7, 2017

I thought this was solved but I reached out to one of the teachers that should have gotten the message and they didn't receive it. Ideas?


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7881 replies
  • September 7, 2017

Don't use the 'bubble' notification for starters. It's pretty buggy. I haven't used it for years due to issues with it. The original developer even mentioned a long while ago that if he ever got around to updating the application he would be removing that window style altogether. So that, plus the fact that it hasn't been updated in like 75 years or something probably are factors.
For simple "notifications" like that, I would look at using either the built in Management Action.app or get a copy of Yo, pull it into Xcode and customize it with a different name and icon and build it and deploy. It works much better for this kind of simple notification stuff.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings