output redirection in Unix and C -


i trying run script inside c program using system() command. inside main(), run script , returns results. how can put result of script in string , check conditions? know can files wondering if possible put result string.

sample like:

main() {   system("my_script_sh"); // how can result of my_script_sh } 

you can't use system command that. best thing use popen:

  file *stream;   char buffer[150];       stream = popen("ls", "r");   while ( fgets(buffer, 150, stream) != null ){       // copy buffer output string etc.   }    pclose(stream); 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -