Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #23974

Re: Wrapping existing UNIX commands in C

From Stephen Sprunk <stephen@sprunk.org>
Newsgroups comp.lang.c
Subject Re: Wrapping existing UNIX commands in C
Date 2012-07-30 13:18 -0500
Organization A noiseless patient Spider
Message-ID <jv6j4v$kdk$1@dont-email.me> (permalink)
References <jv3jqk$r1t$1@speranza.aioe.org> <jv3q1s$c09$1@dont-email.me> <jv6f6j$c9n$1@speranza.aioe.org>

Show all headers | View raw


On 30-Jul-12 12:10, Chicken McNuggets wrote:
> On 29/07/2012 17:57, Stephen Sprunk wrote:
>> If you've already decided to limit portability to POSIX systems, pipes
>> are the general solution for what you're trying to do, but may not be
>> the optimal solution.  For instance, in the case of "ls", why not just
>> call the functions in <dirent.h> yourself rather than opening a pipe to
>> a program that calls them for you and then writing an enormous amount of
>> code to parse its output to extract the same data?
> 
> Because the "ls" command was an example. I really want to process the
> output of things like "iostat", "/proc/loadavg", "sar" and "tcpdump".

As I said, pipes are the general solution.

The source for all of those should be available, so you'd have to
figure out whether it'd be more optimal (for your specific needs) to
crib the logic and API calls to get the data you need directly rather
than using pipes and parsing the output.  Maybe, maybe not.

> dirent.h would be great if I needed to analyse information about
> directories but since I don't need that functionality (and I have
> already used it in the past) it is a rather pointless suggestion.

Obviously, I could only respond to the specific example you gave.

S

-- 
Stephen Sprunk         "God does not play dice."  --Albert Einstein
CCIE #3723         "God is an inveterate gambler, and He throws the
K5SSS        dice at every possible opportunity." --Stephen Hawking

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Wrapping existing UNIX commands in C Chicken McNuggets <chicken@mcnuggets.com> - 2012-07-29 16:11 +0100
  Re: Wrapping existing UNIX commands in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-07-29 11:18 -0400
    Re: Wrapping existing UNIX commands in C Chicken McNuggets <chicken@mcnuggets.com> - 2012-07-29 16:24 +0100
    Re: Wrapping existing UNIX commands in C "China Blue [Tor], Meersburg" <chine.bleu@yahoo.com> - 2012-07-29 08:34 -0700
      Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-07-29 12:05 -0700
        Re: Wrapping existing UNIX commands in C "China Blue [Tor], Meersburg" <chine.bleu@yahoo.com> - 2012-07-29 14:00 -0700
          Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-07-29 15:19 -0700
          Re: Wrapping existing UNIX commands in C Rui Maciel <rui.maciel@gmail.com> - 2012-07-30 00:35 +0100
            Re: Wrapping existing UNIX commands in C Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-07-30 14:54 +0000
              Re: Wrapping existing UNIX commands in C Chicken McNuggets <chicken@mcnuggets.com> - 2012-07-30 17:15 +0100
              Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-07-30 12:44 -0400
                Re: Wrapping existing UNIX commands in C Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-08-02 13:51 +0000
          Re: Wrapping existing UNIX commands in C jacob navia <jacob@spamsink.net> - 2012-07-30 11:13 +0200
          Re: Wrapping existing UNIX commands in C Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-07-30 01:59 -0700
    Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-07-29 17:10 +0000
      Re: Wrapping existing UNIX commands in C tom st denis <tom@iahu.ca> - 2012-07-31 14:55 -0700
        Re: Wrapping existing UNIX commands in C jacob navia <jacob@spamsink.net> - 2012-08-01 00:24 +0200
          Re: Wrapping existing UNIX commands in C tom st denis <tom@iahu.ca> - 2012-08-02 06:12 -0700
  Re: Wrapping existing UNIX commands in C "Heinrich Wolf" <invalid@invalid.invalid> - 2012-07-29 17:20 +0200
    Re: Wrapping existing UNIX commands in C Chicken McNuggets <chicken@mcnuggets.com> - 2012-07-29 16:24 +0100
    Re: Wrapping existing UNIX commands in C Ike Naar <ike@sverige.freeshell.org> - 2012-07-29 21:41 +0000
      Re: Wrapping existing UNIX commands in C "Heinrich Wolf" <invalid@invalid.invalid> - 2012-07-30 06:46 +0200
    Re: Wrapping existing UNIX commands in C "Heinrich Wolf" <invalid@invalid.invalid> - 2012-07-30 06:49 +0200
  Re: Wrapping existing UNIX commands in C "China Blue [Tor], Meersburg" <chine.bleu@yahoo.com> - 2012-07-29 08:31 -0700
    Re: Wrapping existing UNIX commands in C Ike Naar <ike@sverige.freeshell.org> - 2012-07-29 21:46 +0000
  Re: Wrapping existing UNIX commands in C Stephen Sprunk <stephen@sprunk.org> - 2012-07-29 11:57 -0500
    Re: Wrapping existing UNIX commands in C Nobody <nobody@nowhere.com> - 2012-07-30 12:13 +0100
      Re: Wrapping existing UNIX commands in C jacob navia <jacob@spamsink.net> - 2012-07-30 13:26 +0200
        Re: Wrapping existing UNIX commands in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-30 12:39 +0100
          Re: Wrapping existing UNIX commands in C Mark Bluemel <mark_bluemel@pobox.com> - 2012-07-30 13:16 +0100
            Re: Wrapping existing UNIX commands in C BGB <cr88192@hotmail.com> - 2012-07-30 12:39 -0500
          Re: Wrapping existing UNIX commands in C Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-07-30 15:02 +0000
        Re: Wrapping existing UNIX commands in C Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-07-30 15:18 +0000
        Re: Wrapping existing UNIX commands in C Nobody <nobody@nowhere.com> - 2012-07-31 14:53 +0100
        Re: Wrapping existing UNIX commands in C tom st denis <tom@iahu.ca> - 2012-08-02 06:21 -0700
    Re: Wrapping existing UNIX commands in C Chicken McNuggets <chicken@mcnuggets.com> - 2012-07-30 18:10 +0100
      Re: Wrapping existing UNIX commands in C Paul <nospam@needed.com> - 2012-07-30 13:30 -0400
      Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-07-30 13:34 -0400
        Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-15 21:21 +0000
          Re: Wrapping existing UNIX commands in C Stephen Sprunk <stephen@sprunk.org> - 2012-08-15 17:17 -0500
      Re: Wrapping existing UNIX commands in C Stephen Sprunk <stephen@sprunk.org> - 2012-07-30 13:18 -0500
      Re: Wrapping existing UNIX commands in C Cal Dershowitz <cal@example.invalid> - 2012-08-01 21:08 -0600
        Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-02 12:20 +0000
          Re: Wrapping existing UNIX commands in C tom st denis <tom@iahu.ca> - 2012-08-02 06:15 -0700
            Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-02 14:16 +0000
              Re: Wrapping existing UNIX commands in C Kenneth Brody <kenbrody@spamcop.net> - 2012-08-02 11:33 -0400
              Re: Wrapping existing UNIX commands in C tom st denis <tom@iahu.ca> - 2012-08-02 11:51 -0700
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-02 15:03 -0700
                Re: Wrapping existing UNIX commands in C tom st denis <tom@iahu.ca> - 2012-08-02 18:46 -0700
                Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-03 02:18 +0000
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-02 21:07 -0700
                Re: Wrapping existing UNIX commands in C Chicken McNuggets <chicken@mcnuggets.com> - 2012-08-04 10:40 +0100
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-04 03:22 -0700
                Re: Wrapping existing UNIX commands in C "Heinrich Wolf" <invalid@invalid.invalid> - 2012-08-04 12:34 +0200
                Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-04 13:25 +0000
                Re: Wrapping existing UNIX commands in C Kenneth Brody <kenbrody@spamcop.net> - 2012-08-15 13:52 -0400
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-04 16:26 -0700
                Re: Wrapping existing UNIX commands in C Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-08-05 03:27 -0700
                Re: Wrapping existing UNIX commands in C gwowen <gwowen@gmail.com> - 2012-08-06 01:50 -0700
                Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-08-06 07:15 -0400
                Re: Wrapping existing UNIX commands in C gwowen <gwowen@gmail.com> - 2012-08-06 04:25 -0700
                Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-08-06 09:14 -0400
                Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-06 14:14 +0000
                Re: Wrapping existing UNIX commands in C gwowen <gwowen@gmail.com> - 2012-08-06 07:43 -0700
                Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-08-06 11:52 -0400
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-06 11:37 -0700
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-06 11:34 -0700
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-06 11:53 -0700
                Re: Wrapping existing UNIX commands in C gwowen <gwowen@gmail.com> - 2012-08-07 00:33 -0700
                Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-08-07 06:44 -0400
                Re: Wrapping existing UNIX commands in C gwowen <gwowen@gmail.com> - 2012-08-07 05:15 -0700
                Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-08-07 08:37 -0400
                Re: Wrapping existing UNIX commands in C Neil Cerutti <neilc@norwich.edu> - 2012-08-07 13:04 +0000
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-07 12:57 -0700
                Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-07 21:24 +0000
                Re: Wrapping existing UNIX commands in C Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-08-08 00:58 -0700
                Re: Wrapping existing UNIX commands in C "BartC" <bc@freeuk.com> - 2012-08-06 18:04 +0100
                Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-06 18:24 +0000
                Re: Wrapping existing UNIX commands in C jgk@panix.com (Joe keane) - 2012-08-22 17:08 +0000
                Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-08-06 14:46 -0400
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-06 11:55 -0700
                Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-08-06 19:13 -0400
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-08-06 11:50 -0700
                Re: Wrapping existing UNIX commands in C "BartC" <bc@freeuk.com> - 2012-08-06 20:28 +0100
                Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-08-06 15:44 -0400
                Re: Wrapping existing UNIX commands in C Robert Miles <milesrf@Usenet-News.net> - 2012-09-09 22:46 -0500
                Re: Wrapping existing UNIX commands in C Kaz Kylheku <kaz@kylheku.com> - 2012-09-10 04:29 +0000
                Re: Wrapping existing UNIX commands in C Keith Thompson <kst-u@mib.org> - 2012-09-09 22:42 -0700
                Re: Wrapping existing UNIX commands in C Kaz Kylheku <kaz@kylheku.com> - 2012-09-10 19:15 +0000
                Re: Wrapping existing UNIX commands in C pete <pfiland@mindspring.com> - 2012-09-10 22:25 -0400
                Re: Wrapping existing UNIX commands in C Öö Tiib <ootiib@hot.ee> - 2012-09-10 03:10 -0700
                Re: Wrapping existing UNIX commands in C James Kuyper <jameskuyper@verizon.net> - 2012-09-10 08:01 -0400
                Re: Wrapping existing UNIX commands in C "io_x" <a@b.c.invalid> - 2012-08-07 10:22 +0200
                Re: Wrapping existing UNIX commands in C "China Blue [Tor], Meersburg" <chine.bleu@yahoo.com> - 2012-08-07 01:55 -0700
                Re: Wrapping existing UNIX commands in C gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-07 21:26 +0000
                Re: Wrapping existing UNIX commands in C Rui Maciel <rui.maciel@gmail.com> - 2012-08-08 08:47 +0100
                Re: Wrapping existing UNIX commands in C "Ansel" <tinker454@trytospammenowloser.com> - 2012-08-10 21:58 -0600
                Re: Wrapping existing UNIX commands in C Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-08-07 00:07 -0700
          Re: Wrapping existing UNIX commands in C Kenneth Brody <kenbrody@spamcop.net> - 2012-08-02 11:27 -0400
      Re: Wrapping existing UNIX commands in C Rui Maciel <rui.maciel@gmail.com> - 2012-08-16 09:43 +0100

csiph-web