How to get value of shell commands in variable

Home Forums C Programming How to get value of shell commands in variable

This topic contains 0 replies, has 1 voice, and was last updated by  ElviraGullett 9 years, 3 months ago.

  • Author
    Posts
  • #2139

    Hi all,
    If We are excuting shell command in c program. then how can we get result of that command in variable?

    For example:
    int var;
    var=system(“uname -r”);

    This command gives OS version , But in var variable it gives exit status of that command.
    But I want the OS version in variable.How can we get that?

    Any idea?

    Thanks in advance,
    BKP

You must be logged in to reply to this topic.

0 Shares
Share
+1
Tweet
Share
Stumble