• 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: NSTask failing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask failing


  • Subject: Re: NSTask failing
  • From: Randall Meadows <email@hidden>
  • Date: Fri, 4 Apr 2008 15:00:34 -0600

On Apr 4, 2008, at 2:36 PM, Herb Petschauer wrote:
On 04/04/2008, Randall Meadows <email@hidden> wrote:
NSArray *args = [NSArray arrayWithObjects:
  @"-cf",
  [NSString stringWithFormat:@"\"%@\"", tarFilePath],
  [NSString stringWithFormat:@"\"%@\"", plistPath],
  nil];
tarTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/tar"
arguments:args];
[tarTask waitUntilExit];
int status = [tarTask terminationStatus];

I do something very similar.  The only difference is I'm not
constructing a path via stringWithFormat.  I'm using either NSString's
"fileSystemRepresentation" or NSURL's "path" method to get a well
formed path to pass in as a parameter...

So I wonder what your stringWithFormat results actually look like.

Just as you'd expect; something like

"/Users/randy/Desktop/file.tar"

I did the stringWithFormat: merely to quote the path, but upon reading the docs further, it appears this quoting is unnecessary, so I removed it and just add the variables to the args array directly. I still get the status=2.

Hey wait... why does your tarFilePath end with a "/",

I don't know what you mean...it doesn't. There are \ characters in the code, they are merely to quote the double-quotes within the format string for the compiler, but there are no trailing slashes.


Do try the fileSystemRepresentation method :-)

tarFilePath and plistPath are used extensively elsewhere as naked NSStrings with no problem. But I tried, anyway.


Since fSR returns a const char *, I had to wrap that in an NSString anway, and the result looks *exactly* like the bare NSString to begin with. And yes, the result of using fSR is:

status=2

Still.  :(
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTask failing
      • From: Michael Vannorsdel <email@hidden>
    • Re: NSTask failing
      • From: "Herb Petschauer" <email@hidden>
References: 
 >NSTask failing (From: Randall Meadows <email@hidden>)
 >Re: NSTask failing (From: "Herb Petschauer" <email@hidden>)

  • Prev by Date: Re: core data - beyond the simple example
  • Next by Date: Re: NSTask failing
  • Previous by thread: Re: NSTask failing
  • Next by thread: Re: NSTask failing
  • Index(es):
    • Date
    • Thread