• 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
Command line parameters...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Command line parameters...


  • Subject: Command line parameters...
  • From: Jeff LaMarche <email@hidden>
  • Date: Mon, 22 Aug 2005 15:53:37 -0400

Okay... I'm trying to build an objective-C foundation tool, and I'm a little (okay, a lot) rusty on writing command line programs.

I know how to use argc and argv, but I want to my program to additionally operate on piped in data. For some reason, I must be choosing poor search terms, because Google hasn't been much help. I want to be able to do something like this:

cat binarydatafile | myfoundationtool parm1 parm2

I know I can get parm1 and parm2 from argv, but I'm not sure how to pull in the binary data that was piped to my app. I assumed I would just read from stdin, something like this (BUF_SIZE is #defined to 1000) :

NSMutableData *data = [NSMutableData data];
char buffer[BUF_SIZE];
while ( (n=read(stdin, buffer, BUF_SIZE)) > 0)
{
    [data appendBytes:buffer length:n];
}

But I always end up with data being 0 bytes long, no matter what I pipe in.

I know I'm doing something stupid, but if someone can enlighten me, I'd appreciate it.

Thanks,
Jeff

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Command line parameters...
      • From: Aaron Tuller <email@hidden>
    • Re: Command line parameters...
      • From: Cameron Hayne <email@hidden>
  • Prev by Date: bug tracking
  • Next by Date: Re: bug tracking
  • Previous by thread: Re: bug tracking
  • Next by thread: Re: Command line parameters...
  • Index(es):
    • Date
    • Thread