FILE *f; char buf[1024]; f=popen("the bash command you'd like","r"); while (!feof(f)) { if (fgets(buf, sizeof(buf), f)) { printf("%s",buf); } }