Welcome to Soft32 Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

GUI wrapper for command line application

 
   Soft32 Home -> Mac -> Programmer Help RSS
Next:  Carbon/TWAIN issues...  
Author Message
Carlo Noben

External


Since: Mar 01, 2004
Posts: 4



(Msg. 1) Posted: Mon Mar 01, 2004 9:29 am
Post subject: GUI wrapper for command line application
Archived from groups: comp>sys>mac>programmer>help (more info?)

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
Back to top
Login to vote
Michael Ash

External


Since: Mar 01, 2004
Posts: 20



(Msg. 2) Posted: Mon Mar 01, 2004 9:29 am
Post subject: Re: GUI wrapper for command line application [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 1 Mar 2004, Carlo Noben wrote:

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

Details. What is giving you a 'not found' error? Where are you putting it
in the bundle? How are you starting it?
Back to top
Login to vote
Michael Ash

External


Since: Mar 01, 2004
Posts: 20



(Msg. 3) Posted: Mon Mar 01, 2004 9:29 am
Post subject: Re: GUI wrapper for command line application [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 1 Mar 2004, Carlo Noben wrote:

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

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.

> Sorry for not being more specific right away.

No problem, just keep in mind that if we have no idea what's going on, we
can't help very much. Smile
Back to top
Login to vote
Carlo Noben

External


Since: Mar 01, 2004
Posts: 4



(Msg. 4) Posted: Mon Mar 01, 2004 11:15 am
Post subject: Re: GUI wrapper for command line application [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

in article 20040301104725.G8539.DeleteThis@agamemnon.twistedsys.net, Michael Ash at
mikeash.DeleteThis@mikeash.com wrote on 3/1/04 4:49 PM:

> On Mon, 1 Mar 2004, Carlo Noben wrote:
>
>> 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.
>
> Details. What is giving you a 'not found' error? Where are you putting it
> in the bundle? How are you starting it?

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
Back to top
Login to vote
Carlo Noben

External


Since: Mar 01, 2004
Posts: 4



(Msg. 5) Posted: Mon Mar 01, 2004 12:19 pm
Post subject: Re: GUI wrapper for command line application [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

in article 20040301112344.U8539 DeleteThis @agamemnon.twistedsys.net, Michael Ash at
mikeash DeleteThis @mikeash.com wrote on 3/1/04 5:30 PM:

> On Mon, 1 Mar 2004, Carlo Noben wrote:
>
>> searchTask=[[TaskWrapper alloc] initWithController:self arguments:[NSArray
>> arrayWithObjects:
>> @"/Volumes/Titanium/Applications/guitool/build/guitool/Contents/tool",
>> [findTextField stringValue], nil]];
>
> 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.
>

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

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

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
Back to top
Login to vote
Uli Kusterer

External


Since: Jun 22, 2005
Posts: 268



(Msg. 6) Posted: Mon Mar 01, 2004 5:51 pm
Post subject: Re: GUI wrapper for command line application [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <BC692042.49E9%carlo.noben@education.lu>,
Carlo Noben <carlo.noben.DeleteThis@education.lu> wrote:

> So I thought I'd put the command line app called 'tool' into the Contents
> folder of the GUI wrapper bundle (called 'guitool')

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

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

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
Back to top
Login to vote
Miro Jurisic

External


Since: May 10, 2004
Posts: 1194



(Msg. 7) Posted: Mon Mar 01, 2004 5:51 pm
Post subject: Re: GUI wrapper for command line application [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <witness-B27B0A.23510301032004 DeleteThis @news.t-online.com>,
Uli Kusterer <witness DeleteThis @t-online.de> wrote:

> In article <BC692042.49E9%carlo.noben@education.lu>,
> Carlo Noben <carlo.noben DeleteThis @education.lu> wrote:
>
> > So I thought I'd put the command line app called 'tool' into the Contents
> > folder of the GUI wrapper bundle (called 'guitool')
>
> Don't put it in /Contents. Put it in /Contents/Resources/ (or was that
> /Contents/MacOS/ ?).

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>
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Shell command line to set Login startup items - What is the shell command line to set Login startup items (like in Account System Preferences) ?

Method or Shell command line to set Login startup item - What is the Ojective C method or shell command line to set Login startup item (like in Account System Preferences) ?

How to read file line by line??? - Hi All, I want to read the file line by line.Is there any API like getline..and also the function like strtok to be u...

Command-Option-D - Hello out there, In our application we have Command-Option-D assigned to a menu command. In Mac OS 10.1, our applicat...

Error -2110 in open command - Not sure which group this should go to, but I will post here because it is related to development. I am a newbie with r...

"Open" shell command not working in StartupItems - The "test_script" is build from Standard Tool project in Xcode. This tool fork and the child process execl th...
       Soft32 Home -> Mac -> Programmer Help All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
 Windows
 Linux
  Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]