Professional Web Applications Themes

GUI wrapper for command line application - Mac Programming

Hi, I'm trying to write a GUI wrapper for a command line application and am following Apple's Moriarity example. Launching the command line app works fine as long as I put it anywhere *but* the GUI application bundle. If I put it in the bundle (as I would like the program to be self-contained) I get a "not found" error. I made sure that the path is right, but it won't work. What am I doing wrong? Thanks for any suggestions, Carlo...

  1. #1

    Default GUI wrapper for command line application


    Hi,

    I'm trying to write a GUI wrapper for a command line application and am
    following Apple's Moriarity example.

    Launching the command line app works fine as long as I put it anywhere *but*
    the GUI application bundle.

    If I put it in the bundle (as I would like the program to be self-contained)
    I get a "not found" error.

    I made sure that the path is right, but it won't work.

    What am I doing wrong?

    Thanks for any suggestions,

    Carlo

    Carlo Guest

  2. #2

    Default Re: GUI wrapper for command line application

    On Mon, 1 Mar 2004, Carlo Noben wrote:
     

    Details. What is giving you a 'not found' error? Where are you putting it
    in the bundle? How are you starting it?
    Michael Guest

  3. #3

    Default Re: GUI wrapper for command line application

    in article twistedsys.net, Michael Ash at
    com wrote on 3/1/04 4:49 PM:
     
    >
    > Details. What is giving you a 'not found' error? Where are you putting it
    > in the bundle? How are you starting it?[/ref]

    This is how Apple's code does it:

    searchTask=[[TaskWrapper alloc] initWithController:self arguments:[NSArray
    arrayWithObjects:"/usr/bin/locate",[findTextField stringValue],nil]];

    So I thought I'd put the command line app called 'tool' into the Contents
    folder of the GUI wrapper bundle (called 'guitool') and invoke it with the
    following command:

    searchTask=[[TaskWrapper alloc] initWithController:self arguments:[NSArray
    arrayWithObjects:
    "/Volumes/Titanium/Applications/guitool/build/guitool/Contents/tool",
    [findTextField stringValue], nil]];

    But as I said in my initial message this doesn't work and gives me the
    following error in Xcode:

    2004-03-01 17:12:55.157 tool[454] launch path not accessible

    when clicking the 'Start' button in the GUI wrapper.


    Sorry for not being more specific right away.


    Carlo

    Carlo Guest

  4. #4

    Default Re: GUI wrapper for command line application

    On Mon, 1 Mar 2004, Carlo Noben wrote:
     

    Unless you're being really nonstandard, you're missing the ".app"
    extension from your application's bundle name. What you see in the Finder
    doesn't always match what the filesystem actually contains.

    The right way to do this is to put the tool in your bundle's Resources
    folder, and then use [[NSBundle mainBundle] pathForResource:ofType:] to
    get its path. That way it will work even if you move the app, and you
    don't run the risk of making typos or forgetting extensions.
     

    No problem, just keep in mind that if we have no idea what's going on, we
    can't help very much. :)
    Michael Guest

  5. #5

    Default Re: GUI wrapper for command line application

    in article twistedsys.net, Michael Ash at
    com wrote on 3/1/04 5:30 PM:
     
    >
    > Unless you're being really nonstandard, you're missing the ".app"
    > extension from your application's bundle name. What you see in the Finder
    > doesn't always match what the filesystem actually contains.
    >[/ref]

    Oops, I feel really stupid now. Indeed, I forgot to add the .app extension.
    It works perfectly now.
     

    Incidentally, I tried this first, but couldn't get it to work either. So I
    wanted to try it a hard coded path first. I just found out that I omitted
    the ofType:"" parameter (as command line tools normally don't have a
    Creator nor Type, so I just made it empty). Now that version works
    perfectly, too.


    Thank you very much for your help!

    Carlo

    Carlo Guest

  6. #6

    Default Re: GUI wrapper for command line application

    In article <BC692042.49E9%lu>,
    Carlo Noben <lu> wrote:
     

    Don't put it in /Contents. Put it in /Contents/Resources/ (or was that
    /Contents/MacOS/ ?).
     

    Your application isn't named guitool. It is named guitool.app. That's
    why it can't be found. And don't hard-code the path, instead use:

    [[NSBundle mainBundle] pathForAuxiliaryExecutable: "tool"]

    or

    [[NSBundle mainBundle] pathForResource: "tool" ofType: ""]

    Cheers,
    -- Uli
    http://www.zathras.de
    Uli Guest

  7. #7

    Default Re: GUI wrapper for command line application

    In article <t-online.com>,
    Uli Kusterer <de> wrote:
     
    >
    > Don't put it in /Contents. Put it in /Contents/Resources/ (or was that
    > /Contents/MacOS/ ?).[/ref]

    Contents/MacOS if it's architecture-specific, Contents/Resources if it's not
    (i.e. a shell script)

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

Similar Threads

  1. use of xml in perl application to describe command line logic
    By strepxe@yahoo.co.uk in forum PERL Modules
    Replies: 2
    Last Post: December 21st, 10:58 PM
  2. Replies: 4
    Last Post: February 13th, 03:31 PM
  3. command-line
    By Silverfox in forum PERL Beginners
    Replies: 3
    Last Post: November 2nd, 12:17 PM
  4. RUN/execute a Command-Line command from an ASP page
    By Lucas Cowald in forum ASP.NET Building Controls
    Replies: 1
    Last Post: October 22nd, 04:26 PM
  5. RUN/execute a Command-Line command from an ASP page.
    By Lucas Cowald in forum ASP Components
    Replies: 7
    Last Post: October 22nd, 01:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139