Command line parameters...
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