Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can bash script be converted into a very small PPC application?

I am trying to find a simple way to convert a bash script into a compact PPC application for Tiger and Leopard without third party applications or AppleScript.


The are many web pages saying that the following works and probably a similar number saying that it does not.


mkdir -p foo.app/Contents/MacOS

mv foo.command foo.app/Contents/MacOS/foo

chmod +x foo.app/Contents/MacOS/foo


It seldom works for my test script:


#!/bin/bash

say ping


I normally get the following on Tiger: 'You cannot open the application "foo.app" because it is not supported on this system' and a similar message on Leopard.


I can sometimes get it working for a while if I modify an established working application but playing with it or rebuilding launch services database stops it working.


I would like to know why it fails. Is it that the hardware and software can support it but launch services and/or some other security inhibits it?


Can bash script be converted into a very small PPC application?

Posted on Aug 13, 2013 10:06 AM

Reply
26 replies

Aug 14, 2013 11:28 AM in response to twtwtw

twtwtw wrote:


MrHoffman wrote:


Ignoring the folks and their... rocks.... 😉


The only rocks that need to be ignored are the ones in my head - 😀


But just to (I think) solve this problem: open the applescript editor and copy in the following text (obviously replacing the fake path with the real unix path - properly quoted - to your shell script):


do shell script "/[PATH-TO-FILE]/shell_script.sh"


Save this from the applescript editor as an application. Once that's saved, open the application bundle of that app, open the info.plist file in a plain-text editor (like TextWrangler), and add a key-value pair that looks like:


<key>CFBundleIdentifier</key>

<string>user.scriptapp.somename</string>


That should give you a bundled app that you can apply a keyboard shortcut to.


Perhaps you should have read the first sentence of this thread.

Aug 14, 2013 12:01 PM in response to Neville Hillyer

Neville Hillyer wrote:


Perhaps you should have read the first sentence of this thread.


I did read that sentence. Applescript applications are stand-alone cocoa applications that function just like any other application. You would not be able to tell the difference between this applescript application and the PPC app you discuss in your first post, save that the applescript application will likely work. I suggest you try it out before you dismiss it; that will take you, what? 60 seconds?


Believe me, I understand the desire to solve the problem the way you imagine the problem should be solved. But I find it's usually better to get some solution working first. Once you've got a working solution, you can piddle with finding the perfect solution at a leisurely pace.

Aug 14, 2013 12:15 PM in response to twtwtw

I have used AppleScript like this many times.


Perhaps I did not make it clear that my purpose here is to improve my understanding rather than obtain a series of fixes.


I don't know which is more frustrating, being hijacked by 'rocks' or being in receipt of answers to questions I did not ask.


Perhaps I will have more success with the other thread.

Aug 14, 2013 12:24 PM in response to Neville Hillyer

Well, that was not clear. Normally when people post questions on these forums they are looking to fix specific problems, and based on your first sentence I thought it was a solution you were looking for. Deeper questions usually do go over on the developer forum.


and the 'rocks' thing was just plain good fun, not a hijack. sorry for the confudion

Aug 14, 2013 12:42 PM in response to twtwtw

twtwtw wrote:


Well, that was not clear. Normally when people post questions on these forums they are looking to fix specific problems, and based on your first sentence I thought it was a solution you were looking for. Deeper questions usually do go over on the developer forum.


and the 'rocks' thing was just plain good fun, not a hijack. sorry for the confudion


I apologise for my lack of clarity and will attempt to be more circumspect in future.


Perhaps this forum should be entitled OS X Applications and not OS X Technologies. I took 'Technologies' to be an understanding of the underlying hardware and computer science.

Aug 14, 2013 12:47 PM in response to Neville Hillyer

Neville Hillyer wrote:


I took 'Technologies' to be an understanding of the underlying hardware and computer science.


Oh, that's here too - many of the people you'll find here are the ones you'll find over on the developer forum - it's just not as common. But now that I know what you're really after, I'll rethink the problem. It would be nice if you provided a link to one or two of the webpages where you got the original code.

Aug 14, 2013 1:14 PM in response to Neville Hillyer

ok, after doing a quick test of your shell code on Mountain Lion (which worked), the main thing I can see that might cause issues is that your new-made pakage lacks an info.plist file. info.plist is where launchservices gets info it needs to open the package properly, and while launchservices probably has default values, the default values may not be appropriate in your case. With that in mind, create a file called info.plist in the Contents folder that contains some basic info:


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>CFBundleExecutable</key>

<string>foo</string>

<key>CFBundleIdentifier</key>

<string>user.ppcapp.foo</string>

<key>CFBundleName</key>

<string>foo</string>

<key>CFBundlePackageType</key>

<string>APPL</string>

<key>CFBundleSignature</key>

<string>Q#ww</string>

</dict>

</plist>


CFBundleIdentifier and CFBundleSignature are made-up values (they should be unique to this app). You may not need CFBundlePackageType and CFBundleSignature - those are the old-style file type and creator attributes that were phased out in os X, and there may be other attributes that you need to add - you'll have to compare with info.plist files in applications that work on your system.


creating the info.plist file can be done from the command line as well, but it's a bit more involved.

Aug 14, 2013 2:58 PM in response to twtwtw

twtwtw wrote:


ok, after doing a quick test of your shell code on Mountain Lion (which worked), the main thing I can see that might cause issues is that your new-made pakage lacks an info.plist file. info.plist is where launchservices gets info it needs to open the package properly, and while launchservices probably has default values, the default values may not be appropriate in your case. With that in mind, create a file called info.plist in the Contents folder that contains some basic info:


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>CFBundleExecutable</key>

<string>foo</string>

<key>CFBundleIdentifier</key>

<string>user.ppcapp.foo</string>

<key>CFBundleName</key>

<string>foo</string>

<key>CFBundlePackageType</key>

<string>APPL</string>

<key>CFBundleSignature</key>

<string>Q#ww</string>

</dict>

</plist>


CFBundleIdentifier and CFBundleSignature are made-up values (they should be unique to this app). You may not need CFBundlePackageType and CFBundleSignature - those are the old-style file type and creator attributes that were phased out in os X, and there may be other attributes that you need to add - you'll have to compare with info.plist files in applications that work on your system.


creating the info.plist file can be done from the command line as well, but it's a bit more involved.


Thanks - very interesting - clearly I was wrong in assuming that it might only work on old OSs. I thought I had tried most combinations for the plist but must admit that recent tests relied upon defaults which are reputed to work if every element has the same name. Going to bed now but will try your plist tomorrow.

Aug 14, 2013 3:36 PM in response to Neville Hillyer

Perhaps I did not make it clear that my purpose here is to improve my understanding rather than obtain a series of fixes.


I don't know which is more frustrating, being hijacked by 'rocks' or being in receipt of answers to questions I did not ask.


Perhaps I will have more success with the other thread.



Why would you mark your discussion as a question if your main concern was not receiving an answer to the question?


Perhaps you would have more success in both improving your understanding and solving your question if you weren't so dismissive to people whom are volunteering their own time for both.


Cheers.

Aug 18, 2013 1:34 PM in response to twtwtw

twtwtw wrote:


ok, after doing a quick test of your shell code on Mountain Lion (which worked), the main thing I can see that might cause issues is that your new-made pakage lacks an info.plist file. info.plist is where launchservices gets info it needs to open the package properly, and while launchservices probably has default values, the default values may not be appropriate in your case. With that in mind, create a file called info.plist in the Contents folder that contains some basic info:


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>CFBundleExecutable</key>

<string>foo</string>

<key>CFBundleIdentifier</key>

<string>user.ppcapp.foo</string>

<key>CFBundleName</key>

<string>foo</string>

<key>CFBundlePackageType</key>

<string>APPL</string>

<key>CFBundleSignature</key>

<string>Q#ww</string>

</dict>

</plist>


CFBundleIdentifier and CFBundleSignature are made-up values (they should be unique to this app). You may not need CFBundlePackageType and CFBundleSignature - those are the old-style file type and creator attributes that were phased out in os X, and there may be other attributes that you need to add - you'll have to compare with info.plist files in applications that work on your system.


creating the info.plist file can be done from the command line as well, but it's a bit more involved.


Sorry to take so long. I got it working. Diagnostics on Tiger very slightly better than Leopard. It did not need a plist. All the issues were with the bash file:


'say ping' does not work on my Tiger or Leopard it needs to be '/usr/bin/say ping'. Pity this error invoked such a misleading error message - see first post.


Thanks again for your help.

Can bash script be converted into a very small PPC application?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.