linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Xin Zou" <zouxin2008@gmail.com>
To: Jai Sharma <jai.unix@gmail.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: command output to variables
Date: Wed, 7 Jan 2009 20:54:17 +0800	[thread overview]
Message-ID: <e9d800340901070454w4f4b2ef4yb9cdc43019fb8736@mail.gmail.com> (raw)
In-Reply-To: <1f714d50901070435h4b76e26brdb1eedddbdda4cc3@mail.gmail.com>

It's not easy to get output in C.
You can use pipe to get the result from standard output.

On Wed, Jan 7, 2009 at 8:35 PM, Jai Sharma <jai.unix@gmail.com> wrote:
> Hi All
>
> I m PHP, Perl programmer , but finally I need C to program in LInux.
> In perl I simply use `` operator to get command output.
>
> $who_output = `who` ;
>
>
> but in C , how can i get the output. Using system function i m easily
> run the command. But how to get its output .
>
> system("who");
>
> Plz help
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  reply	other threads:[~2009-01-07 12:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-07 12:35 command output to variables Jai Sharma
2009-01-07 12:54 ` Xin Zou [this message]
2009-01-07 13:33 ` Michele Mondelli
2009-01-07 14:59   ` Jai Sharma
2009-01-10 14:57   ` Jason
2009-01-07 14:31 ` Bert Wesarg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e9d800340901070454w4f4b2ef4yb9cdc43019fb8736@mail.gmail.com \
    --to=zouxin2008@gmail.com \
    --cc=jai.unix@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).