• 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: Re: NSTask not using arguments?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: NSTask not using arguments?


  • Subject: Re: Re: NSTask not using arguments?
  • From: <email@hidden>
  • Date: Fri, 25 Feb 2005 5:10:34 +0000

> From: Sherm Pendley <email@hidden>
>
> Right. The launch path would be "/bin/sh". The first argument "-c", and
> the second the complete command you wanted to execute. It would be a
> really good idea to include fully-qualified path names.

Actually, Douglas Davidson's suggestion on getting the file looks to be a more streamlined approach.  I kinda thought there would be.

> As Andy pointed out, it would be a good idea to allow for spaces and
> other characters that might appear in file names. You could do that
> yourself, of course - but why reinvent the wheel? :-) Since you're
> using a shell command anyway, it's easier to just use find and xargs:
>
> find /path/to/files -name '*.ext' -print0 | xargs -0 /path/to/command
>
> Find will list the file names it finds, with NULs as separators. Xargs,
> with the -0 switch, expects a list of NUL-separated strings as its
> input, and will provide those strings as arguments to the command
> specified.

Yes, the spaces in the paths was something I hadn't thought of yet.  I was hardcoding a lot to simulate a somewhat controlled environment (knowing exactly what and where stuff was) to get the actual task completed.  Once I got that done, then I was going to go back and allow for things like that.

I'm not much a UNIX type of guy, still learning, so maybe you could help me out?  How would I format the above command for something such as this: $:> md5sum -b [list of files to process] > md5sum.md5

You say that it will provide those strings as arguments, but the list of files isn't the first argument, there's a switch first.  Again, I'm a bit of a UNIX n00b, but these small programs aren't very complicated to run; they take simple commands and switches and such.  I really like this method of using sh as the task and sending it the one command, seems much easier for what I'm trying to do.  I don't need control over the output of the program, I'd rather just let it do what it's supposed to do.  And if some fancy command line stuff will work better, I just need a little help learning it.

> > I will need, however, to do the infamous "output from NSTask to
> > NSTextView",
>
> Another shell trick - if you want to both read the output from the
> command (so you can display it), and store it to a file, you can add
> the "tee" utility to the chain:
>
> find /path/to/files -name '*.ext' -print0 | xargs -0 /path/to/command |
> tee /path/to/outfile
>
> As its name implies, tee takes its input - which will be the output
> piped from "command" - and writes it to the specified file, as well as
> echoing it to its stdout.
>

Actually, for the task that I'll need to pipe the output to the NSTextView, I don't need to save it to a file, just need to display it to the NSTextView.

Thanks again for all your help, Sherm.  Much appreciated.

James

 _______________________________________________
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: NSTask not using arguments?
      • From: Sherm Pendley <email@hidden>
  • Prev by Date: NSArrayController/Shared Defaults fun & games [solved]
  • Next by Date: NSTextView undo problem
  • Previous by thread: Re: Re: NSTask not using arguments?
  • Next by thread: Re: NSTask not using arguments?
  • Index(es):
    • Date
    • Thread