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 9156467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:46:58+00:00 2026-06-17T12:46:58+00:00

As a learning project Im writing a simple gui for Apache stresstesting command line

  • 0

As a learning project Im writing a simple gui for Apache stresstesting command line tool “ab”. It requiers a full URL, including a filename such as index.html or simular, as one of its parameters. If a filename is not specified “ab” echos “Invalid url” and shows a lists of available flags.

I would like to catch this “error” and have tried using NSTasks standarderror output. Can´t really get it to work. Would this even classify as an error that would pipe to a standard error?

Besides validating the URL input before launching the NSTask, do you think I can prevent or rather catch this error?

My simple code:

- (void) stressTest:(NSString *)url withNumberOfRequests:(int)requests sendSimultaneously:(int)connections {

    NSBundle *mainBundle = [NSBundle mainBundle];
    NSString *abPath = [[mainBundle bundlePath] stringByAppendingString:@"/Contents/Resources/ab"];

    NSString* requestsStr = [NSString stringWithFormat:@"%i", requests];
    NSString* connectionsStr = [NSString stringWithFormat:@"%i", connections];

    // Init objects for tasks and pipe
    NSTask *abCmd = [NSTask new];
    NSPipe *outputPipe = [NSPipe pipe];
    [abCmd setLaunchPath:abPath];
    [abCmd setArguments:[NSArray arrayWithObjects:@"-n", requestsStr, @"-c", connectionsStr, url, nil]];
    [abCmd setStandardOutput:outputPipe];
    [abCmd launch];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readCompleted:) name:NSFileHandleReadToEndOfFileCompletionNotification object:[outputPipe fileHandleForReading]];
    [[outputPipe fileHandleForReading] readToEndOfFileInBackgroundAndNotify];
}

- (void)readCompleted:(NSNotification *)notification {

    NSString * tempString = [[NSString alloc] initWithData:[[notification userInfo] objectForKey:NSFileHandleNotificationDataItem] encoding:NSASCIIStringEncoding];
   [resultTextOutlet setString:tempString];
   [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:[notification object]];
}
  • 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-06-17T12:46:59+00:00Added an answer on June 17, 2026 at 12:46 pm

    ab writes its error messages, including usage information, to standard error. You’re currently only reading from standard output. To access the error messages or usage information you’ll need to allocate a second NSPipe, pass it to -[NSTask setStandardError:], and then read data from it.

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

Sidebar

Related Questions

I'm writing a simple project management app as a learning exercise in Rails. I
This question is for learning purposes. Suppose I am writing a simple SQL admin
(Note: I'm writing this project for learning only; comments about it being redundant are...
I'm learning haskell, and my current project is writing a parser to read a
Hi there I am learning OOP by writing a dummy Library management project in
As a hobby/learning project, I'm writing a parser generator in Python. One of my
I've been writing a blog as a learning project for a while now and
I am writing a learning project in ASP.NET MVC. I have a page Books
As a learning project, I'm using MongoDB with Bottle for a web service. What
So I'm working on just a learning project to expose myself to doing some

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.