Re: [Cocoadialog-users] Bourne Shell Script Equivalent to Perl Script Sample for CocoaDialog Dropdo
Status: Beta
Brought to you by:
sporkstorms
From: Bill L. <wl...@sw...> - 2008-12-01 05:43:52
|
On Nov 30, 2008, at 12:35 PM, Thomas Patko wrote: > Hello CocoaDialog Users: > > I am trying to integrate CocoaDialog with some drag and drop run > applications that I am building with Platypus. I saw one of the > Cocoa dialog that would be quite useful for such a purpose, the > dropdown. I am however using Bourne shell script to build these > little applications rather than Perl. Is there an example of a > Bourne shell script equivalent to the perl scrip example provided? > > http://cocoadialog.sourceforge.net/examples/dropdown.pl.txt > > I would be appreciative of any assistance towards this end. > > Best Regards, You need to play around a little. There are examples provided of using CocoaDialog with shell scripts. Take these, along with the documentation for the dropdown function and put together a shell script and test it out. I tossed together the following script that duplicates the function of the Perl script that provides a dropdown menu. Use it as an example. #!/bin/sh CD="/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog" result=`$CD dropdown \ --title "Preferred OS" \ --no-newline \ --items "Mac OS X" "GNU/Linux" "Windows" \ --button1 'That one!' \ --button2 Nevermind` return=`echo $result | awk '{print $1}'` answer=`echo $result | awk '{print $2}'` if [ $return -eq 1 ]; then echo "Answer: $answer" fi if [ $return -eq 2 ]; then echo "Nevermind" fi Please note, I make NO claims that this is a "good" script, nor do I like using "awk" in this manner, but it does seem to work. |