Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Directing output of shell output called in system() function (http://www.go4expert.com/forums/directing-output-shell-output-called-t21274/)

uengin 10Mar2010 11:35

Directing output of shell output called in system() function
 
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:

karthigayan 10Mar2010 13:57

Re: Directing output of shell output called in system() function
 
As of my knowledge , there is no way other than writing to a file, and reading it.

refer the following url ,

http://cboard.cprogramming.com/c-pro...-variable.html

uengin 25Mar2010 09:59

Re: Directing output of shell output called in system() function
 
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 :-)


All times are GMT +5.5. The time now is 18:37.