Previous 1 2 Next 26 Replies Latest reply: Aug 18, 2013 1:34 PM by Neville Hillyer
Neville Hillyer Level 4 Level 4

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?

Solved by Neville Hillyer on Aug 18, 2013 1:34 PM Solved

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.

Reply by twtwtw on Aug 14, 2013 1:14 PM Helpful

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.

All replies

  • BobHarris Level 6 Level 6

    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).

  • twtwtw Level 5 Level 5

    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. 

  • BobHarris Level 6 Level 6

    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.   blush.gif

     

    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.

     

    BeachStoneOnGraniteChip.jpg

  • twtwtw Level 5 Level 5

    BobHarris wrote:

     

    It is a Beach Stone on a Granite Chip.

     

    lol - Ok...  It might be time for me to invest in some new reading glasses.

  • MrHoffman Level 6 Level 6

    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...)

  • BobHarris Level 6 Level 6

    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'

  • Neville Hillyer Level 4 Level 4

    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.

  • Neville Hillyer Level 4 Level 4

    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.

  • Neville Hillyer Level 4 Level 4

    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?

  • MrHoffman Level 6 Level 6

    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.

  • nbar Level 5 Level 5

    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.


  • VikingOSX Level 6 Level 6
    expertise.macosx
    Mac OS X

    Spitbrook Rd. Been there done that.

  • Neville Hillyer Level 4 Level 4

    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.

  • MrHoffman Level 6 Level 6

    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.

Previous 1 2 Next