Re: Problem with arguments of an NSTask
Re: Problem with arguments of an NSTask
- Subject: Re: Problem with arguments of an NSTask
- From: "devdrvr.net Multi-Platform SW" <email@hidden>
- Date: Tue, 29 Oct 2002 07:53:36 -0800
Arthur,
Sendmail takes multiple arguments. Here's an extract of code from a past
project where I made a cheesy reporting mechanism happen for beta users in
certain conditions. It shows the Objective-C syntax of what you might want
to do with your array of strings.
--Perry
========
01 (530) 400-5692 [Davis, CA USA]
mailto:email@hidden
http://www.devdrvr.net/PerryCard.html
ftp://www.devdrvr.net/
- (void)reportWithSendmail
{
NSTask *sendmail;
NSPipe *pipe;
NSString *sendmailString;
NSData *data;
sendmail = [[[NSTask alloc] init] autorelease];
[sendmail setLaunchPath:MAILER];
[sendmail setArguments:[NSArray arrayWithObjects:@"-t", nil]];
pipe = [NSPipe pipe];
[sendmail setStandardInput:pipe];
sendmailString = [NSString stringWithFormat:
@"From: %@\nTo: %@\nSubject:
%@\nX-Mailer:ArthurYourMailerHere email@hidden\n\n%@\n",
_senderEmail,
[_recipients componentsJoinedByString:@", "],
_subject, _message];
data = [sendmailString dataUsingEncoding:NSASCIIStringEncoding];
[[pipe fileHandleForWriting] write
Data:data];
[[pipe fileHandleForWriting] closeFile];
[sendmail launch];
[sendmail waitUntilExit];
}
On 10/29/02 4:49 AM, "Arthur VIGAN" <email@hidden> wrote:
>
But when I use:
>
>
NSArray *arguments = [NSArray arrayWithObjects:@"-nice", @"19"];
>
>
I get a EX_BAD_ACCESS error before the task is launched.
>
>
Arthur
>
>
>
>> the following code doesn't work and I don't see where the mistake is:
>
>>
>
>> NSArray *arguments = [NSArray arrayWithObject:@"-nice 19"];
>
>
>
> IIRC, arguments are split by whitespace, so "-nice 19" would actually
>
> be *two* arguments, not just one.
>
>
>
> sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.