From: "Bert Wesarg" <bert.wesarg@googlemail.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 15:31:43 +0100 [thread overview]
Message-ID: <36ca99e90901070631i2522a125uda7502b084758626@mail.gmail.com> (raw)
In-Reply-To: <1f714d50901070435h4b76e26brdb1eedddbdda4cc3@mail.gmail.com>
On Wed, Jan 7, 2009 at 13:35, 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");
use popen("who", "r") and read from the stream into a buffer
Bert
>
> 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
>
prev parent reply other threads:[~2009-01-07 14:31 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
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 [this message]
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=36ca99e90901070631i2522a125uda7502b084758626@mail.gmail.com \
--to=bert.wesarg@googlemail.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).