Use popen() :
http://linux.die.net/man/3/popen