• 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: how to launch a binary as if I launched it via terminal?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTask: how to launch a binary as if I launched it via terminal?


  • Subject: NSTask: how to launch a binary as if I launched it via terminal?
  • From: Colas B <email@hidden>
  • Date: Mon, 14 Apr 2014 14:59:45 +0100 (BST)

Dear cocoa-dev,


I am would like to launch a binary as if I launched it via terminal. I tried the following but it is not working. 

    NSTask * myTask = [[NSTask alloc] init];

    NSArray * arguments = @[@"-c", @"-l", @"'/usr/bin/pico /Users/colas/myfile.txt'"];

    [myTask setCurrentDirectoryPath:@"/"];
    [myTask setLaunchPath:@"/bin/bash"];
    [myTask setArguments:arguments];
    
    [myTask launch] ;

If I execute the same commands in a terminal, it works !!

$ /bin/bash -c -l '/usr/bin/pico /Users/colas/myfile.txt'


Any remark will be appreciated !!
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: how to launch a binary as if I launched it via terminal?
      • From: Bryan Vines <email@hidden>
    • Re: NSTask: how to launch a binary as if I launched it via terminal?
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Automatically resize parent view when subviews resize
  • Next by Date: Re: NSTask: how to launch a binary as if I launched it via terminal?
  • Previous by thread: Re: Automatically resize parent view when subviews resize
  • Next by thread: Re: NSTask: how to launch a binary as if I launched it via terminal?
  • Index(es):
    • Date
    • Thread