Find the answer to your Linux question:
Results 1 to 3 of 3
Hello How to take output of following command/ or any linux shell script in c/c++ program This command return the system memory/ram size. char *szCommand="grep MemTotal /proc/meminfo"; system(szCommand); Is there ...
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Posts
    15

    How to take output of linux shell command in C/C++ program

    Hello

    How to take output of following command/ or any linux shell script in c/c++ program

    This command return the system memory/ram size.

    char *szCommand="grep MemTotal /proc/meminfo";
    system(szCommand);


    Is there any alternative of doing this?

    Thanks
    Ritesh

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    If I understand your question correctly, you wish to examine with your program the output of an executed program or script or shell command line.

    Do this at the command line:
    Code:
    man popen
    If man pages are not installed on your system, google this:
    Code:
    linux man popen
    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Jun 2008
    Posts
    15
    Yes it solves my problem.

    Thanks for quick reply.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...