• 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
Re: Problem with arguments of an NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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] writeData: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.

References: 
 >Re: Problem with arguments of an NSTask (From: Arthur VIGAN <email@hidden>)

  • Prev by Date: selecting output format - NSKeyedArchiver
  • Next by Date: Re: Printable region and drawRect
  • Previous by thread: Re: Problem with arguments of an NSTask
  • Next by thread: Re: Problem with arguments of an NSTask
  • Index(es):
    • Date
    • Thread