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

Re: NSTask not using arguments?


  • Subject: Re: NSTask not using arguments?
  • From: Sherm Pendley <email@hidden>
  • Date: Fri, 25 Feb 2005 12:47:09 -0500

On Feb 25, 2005, at 12:10 AM, <email@hidden> wrote:

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.

We're actually talking about the *same* approach, just different aspects of it. What I meant by "fully-qualified path name" is a path name starting at the root directory - "/". Douglas' suggestion was about how to *get* such a path without hard-coding it in your source, and he's correct.


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.

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.

It's not immediately obvious, but xargs will *append* those strings, after whatever arguments you specify directly. So:


find /path/to/files -name '*.ext' -print0 | xargs -0 md5sum -b > /path/to/md5sum.md5

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.

Yeah, it makes life *so* much easier when you want to use file globs, chain together multiple command-line tools, and such.


sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
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


References: 
 >Re: Re: NSTask not using arguments? (From: <email@hidden>)

  • Prev by Date: Loading Cocoa Bundles
  • Next by Date: Re: Out-of-order enter/exit events
  • Previous by thread: Re: Re: NSTask not using arguments?
  • Next by thread: Binding name must be same as ivar name?
  • Index(es):
    • Date
    • Thread