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 13, 2013 10:15 AM in response to Neville Hillyer

If the script is named something.command, and has the execute bit set, then it will be a double clickable application as is.


What could be easier?


If you do not want the script to open a Terminal window, then you will need to wrap it with something, such as trivial Applescript or Automator wrapper. Platypus is a 3rd party app that can also generate an application wrapper around any script (however, I'm not sure if there is a PowerPC version of Platypus available these days).

Aug 13, 2013 10:25 AM in response to Neville Hillyer

It's been a while since I worked on Tiger, but somewhere along the line it became possible to run shell scripts directly from the Script Menu in the menu bar. You can enable that from the preferences of the applescript editor.


P.s. to Bob: What in heaven's name is that avatar/icon you're using? I can't politely tell you what it looks like without my reading glasses, and I still can't make sense of it when I'm wearing them. 😊

Aug 13, 2013 10:51 AM in response to twtwtw

P.s. to Bob: What in heaven's name is that avatar/icon you're using? I can't politely tell you what it looks like without my reading glasses, and I still can't make sense of it when I'm wearing them. User uploaded file


It is a Beach Stone on a Granite Chip.



The chip came from when a friend installed granite front steps to his New Hampshire (The Granite State) home. The beach stone came from Well's Beach, Maine.



This has been my on-line avatar for years, on many different forums.


User uploaded file

Aug 13, 2013 12:21 PM in response to Neville Hillyer

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


A file with an .app is called a bundle. From the view of the Unix layer, an .app is really a directory filled with files. You can cd /Applications and then cd into some .app bundle for a look around. Your script is not a bundle. In place of .app, you can use .sh or .bash or .command or, well, nothing at all, as the file extension, mark the script as executable, and the script should run (within the limits of bash or whatever shell you're using on the target system). Some of the older logins from back in that era also didn't default to bash, too; the older default shell was a different shell. (Off-hand, I don't recall which one...)

Aug 13, 2013 12:35 PM in response to MrHoffman

Some of the older logins from back in that era also didn't default to bash, too; the older default shell was a different shell. (Off-hand, I don't recall which one...)

tcsh was the original default Mac OS X shell. I do not know when it switched, as I kept migrating to newer versions, and the existing shell was preserved. I finally force the switch to bash around 2005, but I know that was a few years after Mac OS X switched its default for new accounts.


I'm also fairly sure that in earlier versions, only .command was accepted as a double clickable script. Later (and I do not know when), it became more flexible.


One advantage putting an Applescript wrapper around the script is that you can pass dragged and dropped files to the script from the GUI.


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


The granite chip came from a fellow ZKO3-3 'Digit' 🙂

Aug 13, 2013 1:00 PM in response to BobHarris

BobHarris wrote:


If the script is named something.command, and has the execute bit set, then it will be a double clickable application as is.


What could be easier?


If you do not want the script to open a Terminal window, then you will need to wrap it with something, such as trivial Applescript or Automator wrapper. Platypus is a 3rd party app that can also generate an application wrapper around any script (however, I'm not sure if there is a PowerPC version of Platypus available these days).


In my experience it is not always necessary to use the 'command' extension to get bash scripts to be clickable. I particularly want a normal application which can be invoked by a key press via the services menu. I have tried AppleScript which is slightly bloated and slow. Platypus is very bloated.

Aug 13, 2013 1:03 PM in response to twtwtw

twtwtw wrote:


It's been a while since I worked on Tiger, but somewhere along the line it became possible to run shell scripts directly from the Script Menu in the menu bar. You can enable that from the preferences of the applescript editor.


P.s. to Bob: What in heaven's name is that avatar/icon you're using? I can't politely tell you what it looks like without my reading glasses, and I still can't make sense of it when I'm wearing them. 😊


Whilst keyboard shortcuts can be applied to the Scripts Menu they only work if the menu is in focus hence I want a normal application.

Aug 13, 2013 1:09 PM in response to MrHoffman

MrHoffman wrote:


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


A file with an .app is called a bundle. From the view of the Unix layer, an .app is really a directory filled with files. You can cd /Applications and then cd into some .app bundle for a look around. Your script is not a bundle. In place of .app, you can use .sh or .bash or .command or, well, nothing at all, as the file extension, mark the script as executable, and the script should run (within the limits of bash or whatever shell you're using on the target system). Some of the older logins from back in that era also didn't default to bash, too; the older default shell was a different shell. (Off-hand, I don't recall which one...)


I think you will find that my original post showed how to make an application bundle:


mkdir -p foo.app/Contents/MacOS

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

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


Have you tried it? Why do you say it is not a bundle?

Aug 13, 2013 3:58 PM in response to Neville Hillyer

For simplicity and given the bundle scheme is not (yet) working here, I would transport and use the bare script, and not the bundle.


Xcode dropped PPC a while ago; 3.2.6 was the last Xcode release with support for building for PPC, so this is all a ways back. I don't have the old ~10.5 doc handy to see what's changed since then (if anything), but the Info.plist and a few other pieces are generally required.

Aug 14, 2013 4:10 AM in response to nbar

nbar wrote:


Have you tried it? Why do you say it is not a bundle?

There is a difference between compiling and interpreting, which is the essence of what MrHoffman was getting at.


I don't understand why he replies to posts he cannot answer.


I suspect that at some point OS X was changed to require something to be compiled but I have been unable to discover details about the change.


As I said it appears that Leopard can be tricked into accepting raw bash script but eventually it gets discovered and inhibited. This does prove that support is available for it even if it is not intended to be used.


I would like to understand the details of what is happening rather than have a series of fixes I did not ask for.

Aug 14, 2013 7:54 AM in response to Neville Hillyer

Neville Hillyer: you had asked for a simple way to run a bash script on an old PPC box. The bash script should run directly, barring version incompatibilities. If that approach is not suitable for your requirements and if you need or want to use a bundle here and seek assistance with that creation for PPC beyond the Info.plist and related details, then I'd suggest the Apple developer forums if you have access to those, or one of the Apple mailing lists. Both of those resources have more development-related traffic than these forums, and folks that might still deal with or remember the details of the app bundle requirements of the OS X PPC boxes.


My apologies in general for intruding into the discussion, and I'll exit this discussion now.


ps: ZKO and MLO, here.

Aug 14, 2013 9:51 AM in response to MrHoffman

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.

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.