Showing progress bar while running scripts

DirkM2012
Contributor

I manage my Windows clients mostly with a tool call WinBatch. One of the nice features is the option to display a progress bar and update that progress bar while the script is running.

aStatusBar (0,title,message1,10,0) to open the statusbar
aStatusBar (1,title,message2,10,1) to update the statusbar
aStatusBar (2,"","",10,10) to close the statusbar

Is there anything similar for OS X that would allow me to do something like that in a script executed via policy?

Thanks,
Dirk

17 REPLIES 17

alexjdale
Valued Contributor III

I use CocoaDialog which has options for progress bars. You can either have it show a generic animated progress bar that just shows something is happening (with text) or your script can update it to show % completion if you have that data.

I use it in a couple ways, one being a countdown timer (https://jamfnation.jamfsoftware.com/discussion.html?id=8360) and the other being a generic animated bar while I install software updates.

CocoaDialog is great for all sorts of scripted UI interaction.

mm2270
Legendary Contributor III

Yep, what @alexjdale said. CocoaDialog is what you're looking for on the Mac. I use its progress bars quite often and it works well once you understand how it works.
Just be warned. The version that most of use is a beta version that actually hasn't been updated in close to 2 years now. There's no telling when or even if it will ever be updated. For now, it still works pretty well with Mavericks and anything prior, but with each new OS release, all bets are off on if it will continue to work.

jhbush
Valued Contributor II

@mm2270][/url, it's off topic, but I wonder if there is interest from admins who would help fund the further development of Cocoa Dialog. It's like other tools that went from free to donation ware.

mm2270
Legendary Contributor III

@jhbush1973, I'd actually seriously consider contributing something toward its continued development. Its kinda sad that the developers for it have no time to continue to work on it.
I've also toyed around with trying to learn some Cocoa development so I can contribute to the code, fix some issues, etc. But given the lack of time I can devote to learning development, donating something to keeping it alive might be easier.

kalikkalik
New Contributor

Hmmm...was just talking about this earlier. I have about 6 projects on my desk, but I can start looking at CD. I wrote some lightweight equivalents for some clients, but that's their IP now. Either we could dress it up, or start fresh.

What do people really want out of a product like CD?

-jeremy

DirkM2012
Contributor

Thanks @alexjdale and @mm2270, I will take a look at CocoaDialog and see how that works. In general I try to stay away from beta software or quick hacks though, burned my fingers a few times in the Windows world after using tools that weren't really supported. I would rather pay/licence a commercial tool that is fully supported.

corbinmharris
Contributor

It would cost pennies for Apple to buy the IP and integrate it in the next version of OS X.

nessts
Valued Contributor II

Apple already has all the IP that CocoaDialog is built off of included in the OS for free. Not sure why they would waste a second worrying about it. They really could care less about your and my struggles to communicate with the users. I have been using CD for a couple of years now, it is an easy solution that takes seconds to implement, the proper thing would probably be to learn how to be a better Obj-C programmer and just make apps for what we need to do. But until then CD is my solution, regardless of its limitations in some areas.

mm2270
Legendary Contributor III

@dmatth01 - I hear you. Though I'm more concerned about the lack of continued development of CD than I am of it being a "beta" release. Truth is, other than a few quirks that started to show up from about 10.7 and forward, most of it works pretty flawlessly. The beta is a label only and it works more solidly than many non beta products I've used! :-P I have never seen it crash or cause any weird issues on our systems, and I've really pushed CocoaDialog to its limits in some of the scripts I've built around it.
I've also gotten into building lightweight apps from combining Platypus and CocoaDialog together. Embedding CD into a Platypus app can make standalone limited use applications.

@corbin3ci - agreed with the points from @nessts. Apple, as far as they seem to be concerned, feels we all should be using the standard OS included dialogs. Why do we need anything more than that? /sarcasm. They don't get the need for us to display custom dialogs to users. I'm willing to bet they'd just point anyone to Applescript, or Cocoa AppleScript application development for that.

scottb
Honored Contributor

Apple are pushing (no pun intended) for Notification Center use. I would wager that is where they want people to go moving forward.

kalikkalik
New Contributor

NC doesn't allow for rich user feedback. Lots of restrictions.

If you have to go that route, check out CNUserNotification...has a set of classes which approximates appearance and behavior of NC, but lets you do a bunch more....I know since I was working on some changes for terminal-notifier.

...yikes....

scottb
Honored Contributor

Having lots of restrictions doesn't mean Apple isn't pushing for it. As we all know, once they set their collective minds to something, it's set. I wasn't saying it's best. Just, it's Apple.

DirkM2012
Contributor

@boettchs, if that's the case then there should be an easy way to send notifications from a script without using 3rd party software.

scottb
Honored Contributor

@dmatth01: Well, a lot of what you read being done in here is using third-party utilities. I'm not disagreeing with you, but many things being done with Casper use other offerings to fill in the gaps.

mm2270
Legendary Contributor III

Re: being able to send messages easily to Notification Center, while I don't have it on any authority, I strongly suspect the main reason Apple doesn't allow this (at least not easily) is for security reasons. It might be a bit too easy for some malware to send up a convincing looking NC message asking the user to "click" to do something, running some malicious code under it all. This is why normally only developer signed applications can send up Notification Center messages. terminal-notifier can help with this (I use that too!), but even with it, you need to run the call to terminal-notifier and its arguments in the context of the user or else the sandboxing stops it in its tracks. Ugh!

I also suspect a secondary reason they don't allow it is because of Apple's desire to have as much control over the user experience as possible. I sometimes think that if Apple could get away with it, they wouldn't let us control half as much as we can today on OS X. Look no further than iOS as an example of Apple's ideal vision of an Operation System.

nessts
Valued Contributor II

a shining example of being able to do exactly one thing at a time LOL
http://business.time.com/2014/02/20/samsung-mocks-apple-ipad-pencil-commercial/
I found that pretty funny, sorry if it hurts the feelings of any person who chooses to watch it.

bentoms
Release Candidate Programs Tester

You can easily send a NC message via AppleScript.. Which you can, of course, call from bash

http://macosxautomation.com/mavericks/notifications/01.html

Plus Casper V9 has NC support built in.