#include #include int main(int argc, char **argv) { const auto cmd = "./subdir/entry.sh"; FILE *f = popen(cmd, "r"); if (f == NULL) { perror("popen failed"); return EXIT_FAILURE; } char buf[1024]; while (fgets(buf, sizeof(buf), f)) { printf("read: %s", buf); } int ret = pclose(f); if (ret == -1) { perror("pclose failed"); return EXIT_FAILURE; }; printf("Return code: %d", ret); return EXIT_SUCCESS; }