Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Another way to create Finder-clickable shell scripts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another way to create Finder-clickable shell scripts
Authored by: foobar104 on Jul 30, '03 11:19:18AM

There's a better way.

Let's say you have a shell script called foo.sh. Do this:

mkdir -p foo.app/Contents/MacOS
mv foo.sh foo.app/Contents/MacOS/foo
chmod +x foo.app/Contents/MacOS/foo

Done. Double-click foo.app (which the Finder shows you as simply "foo") and your shell script runs. No developer tools required, and it doesn't depend on fragile metadata like this hint does.



[ Reply to This | # ]
Another way to create Finder-clickable shell scripts
Authored by: MacTed on Jul 30, '03 11:20:53PM

I tried this one, cause I like it better than the previous hint -- I can add a nice icon and other frills! -- but this failed for me...

The Finder decided that my foo.app was a Classic App, but didn't bring up the Classic Environment. My script is woefully simple -- it simply calls a Terminal-based executable -- which now launched in the background, with no user interaction...

So I'll stick to the following, as in the older hint, for now -- just change your

foo.sh

to

foo.command

and presto -- auto-launch of the Terminal, and auto-run of the script therein, complete with user interaction.

---
Ted Thibodeau Jr -- Technical Evangelist -- OpenLink Software

[ Reply to This | # ]

Another way to create Finder-clickable shell scripts
Authored by: _merlin on Jul 31, '03 03:42:01AM

You also have to create a file foo.app/Contents/Info.plist containing keys identifying the name of the executable. In this exampe, it would contain:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleExecutable</key>
<string>foo</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.0</string>
</dict>
</plist>



[ Reply to This | # ]
Another way to create Finder-clickable shell scripts
Authored by: foobar104 on Jul 31, '03 09:55:27AM

Nope. You don't actually have to do this.

When you double-click on foo.app, the Finder looks for a file foo.app/Contents/Info.plist. Not finding it, it looks for an executable file with the same name as the base name of the application package: foo.app/Contents/MacOS/foo. It then exec's it.

The only trick is that you have to be sure the file is executable.



[ Reply to This | # ]
Another way to create Finder-clickable shell scripts
Authored by: peterhil on Jul 31, '03 04:49:14AM

Neat hint!

But to make it work, I had to make an Info.plist file in the bundle, which must contain the usual xml headers plus the following key at minimum:

	<key>CFBundleExecutable</key>
	<string>foo</string>

Apple's developer documentation about keys used in the bundles instruct not to use a file name extension for the actual program -- and after dropping the extension the shell script shows as an application inside the bundle too.

I have been looking for a way to make a "droplet" from shell script, so I could drop files into the shell script which would get the dropped files as arguments.

Editing the CFBundleDocumentTypes key in Info.plist didn't seem to achieve this. Does anyone know how this could be done?

This might be a great way to package Python programs too!



[ Reply to This | # ]
AppleScript droplets
Authored by: saint.duo on Jul 31, '03 11:34:43AM
I use applescript to accomplish this. Something along the lines of:
on open myList
   repeat for each myItem
      do shell script "PathToMyShellScript" & " " & myItem
   end repeat
end open
The code may be a little off, as I'm doing this for memory, but the idea works. I use it in my UnButton app, which you can get the source code for at http://www.freefallsoftware.com/products.html

---
--
duo

[ Reply to This | # ]