Directing output of shell output called in system() function

Discussion in 'C' started by uengin, Mar 10, 2010.

  1. uengin

    uengin New Member

    Joined:
    Mar 1, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    I am trying to run a piece of code that calls the cksum and pass its output in to a variable in my code. I realise I can channel it to a text file and then open it and read it in, but this seems very dodgy and so I am hoping for a better way to do it. Please any ideas?

    Code:
    system("cksum /path/to/file")
    :confused:
     
  2. karthigayan

    karthigayan New Member

    Joined:
    Feb 19, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    0
  3. uengin

    uengin New Member

    Joined:
    Mar 1, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    For those of you the come here looking for an answer to this question, I found the solution. You need to use popen().
    just lookup examples and documentation for more detail :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice