Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1105261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:36:14+00:00 2026-05-17T01:36:14+00:00

Here is my code: -(void)startTask{ NSString * cmd = @/bin/sh; pty_ = [[PseudoTTY alloc]

  • 0

Here is my code:

-(void)startTask{
NSString * cmd = @"/bin/sh";
pty_ = [[PseudoTTY alloc] init];

NSTask * task = [[NSTask alloc] init];
[task setStandardInput:[pty_ slaveFileHandle]];
[task setStandardOutput:[pty_ slaveFileHandle]];
[task setStandardError:[pty_ slaveFileHandle]];

[task setCurrentDirectoryPath:[@"~" stringByExpandingTildeInPath]];
[task setLaunchPath:@"/bin/sh /applications/jarvis/brain/server.sh"];

[[NSNotificationCenter defaultCenter]
            addObserver:self
               selector:@selector(didRead:)
                   name:NSFileHandleReadCompletionNotification
                 object:[pty_ masterFileHandle]];

[[pty_ masterFileHandle] readInBackgroundAndNotify];

[task launch];

[self insertText:
    [NSString stringWithFormat:@"Started %@ on terminal %@", cmd, [pty_ name]]];

}

But, instead of this, I need it to start an SH file: /applications/brain/server.sh

I’m confused….

Can someone help me with my code?

thanks,
Elijah

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:36:15+00:00Added an answer on May 17, 2026 at 1:36 am
    [task setCurrentDirectoryPath:[@"~" stringByExpandingTildeInPath]];
    

    You can just call NSHomeDirectory to get the home directory path.

    [task setLaunchPath:@"/bin/sh /applications/jarvis/brain/server.sh"];
    

    This file does not exist. There is no directory named “sh ” within the /bin directory; as such, there is no “applications” subdirectory within that, no “jarvis” subdirectory within that, no “brain” subdirectory within that, and no “server.sh” file within that.

    Remember that NSTask is not the shell. Shell tricks don’t work on it; it doesn’t parse arguments, interpolate environment variables or ~ (notice that you had to do that explicitly), or anything else the shell does. You can only use the shell the same as any other program.

    You need to set the launch path to the path to the shell, and pass the path to the shell script as the first argument. Alternatively, if you know that the shell script file is executable (and has the correct shebang in it), you can pass the path to the script file as the launch path and omit the arguments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the code - (void)viewDidLoad { hauptOptionen = [[NSMutableArray alloc] init]; self.hauptOptionen =
Here is my code: - (void)showRectangles { NSMutableArray *rects = [[NSMutableArray alloc]init]; //....rest of
here is code - (void)applicationDidFinishLaunching:(UIApplication *)application { NSBundle *bundle = [NSBundle mainBundle]; NSString *moviePath
Here is my code - (void)embedYouTube:(NSString*)url frame:(CGRect)frame { UIWebView * videoView; NSString* embedHTML =
Here is my code: //ECHOAppDelegate.m @implementation ECHOAppDelegate ... @end //PtyView.m @interface PtyView (PtyPrivate) -(void)startTask;
log warning: implicit declaration of function 'TutorialAlertWithMessageAndDelegate' here my code .h void TutorialAlertWithMessageAndDelegate(NSString *title,
Here the code : - (void)addAnswerWithNumber:(NSString *)numberAnswer { UIButton *aButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
Here is my code: - (void)viewDidLoad{ [super viewDidLoad]; self.authorList = [[NSArray alloc] initWithObjects:@Christie, Agatha,
Here's my code: - (void)viewDidLoad { [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@index
Here is my code: - (void)loadView { //hard coded array of content for each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.