Re: [Cocoadialog-users] Bourne Shell Script Equivalent to Perl Script Sample for CocoaDialog Dropdo
Status: Beta
Brought to you by:
sporkstorms
From: Thomas P. <tp...@gm...> - 2008-12-01 06:44:07
|
Hello Bill: Thank you very much for the Bourne shell script code and concept. I agree that it is not necessarily the most elegant approach but the combination of --no-newline and the awk '{print $X}' code reliably script out the multiple variables passed back by CocoaDialog. I have made it work quite well for my application, wherein I was only really interested in the second variable. Cheers, Thomas On Sun, Nov 30, 2008 at 9:27 PM, Bill Larson <wl...@sw...> wrote: > 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. > |