• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTask: program launching another program, potential problem with path: how to do?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTask: program launching another program, potential problem with path: how to do?


  • Subject: NSTask: program launching another program, potential problem with path: how to do?
  • From: Colas B <email@hidden>
  • Date: Thu, 10 Apr 2014 13:57:38 +0100 (BST)

Dear cocoa-dev,

I want to do with an `NSTask` what I am able to do in the terminal via

    $ myprogram myfile.ext

I know that `myprogram` (I don't have any control on this program) launches another program `myauxprogram`. Furthermore, the path to `myprogram` is `path1` and the path to `myprogram` is `path2`.

If I do

     NSTask * myTask = [[NSTask alloc] init];
    
     NSArray * arguments = @[@"myfile.ext"] ;
    
     [myTask setCurrentDirectoryPath:[URLOfTheFolder path]];
     [myTask setLaunchPath:@"/path1/myprogram"];
     [myTask setArguments:arguments];
    
     [myTask launch] ;

I get the following error `sh: myauxprogam: command not found`

If I create a symbol link in `path1` to `myauxprogram`, the problem is the same.

How is it that when I execute the program in a terminal, everything goes well but via NSTask it fails? How can I solve this problem?

Thanks,
Colas
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTask: program launching another program, potential problem with path: how to do?
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: NSDictionary @synchronize to read multiple objects
  • Next by Date: Re: NSTask: program launching another program, potential problem with path: how to do?
  • Previous by thread: Re: button cell highlight/state/type
  • Next by thread: Re: NSTask: program launching another program, potential problem with path: how to do?
  • Index(es):
    • Date
    • Thread