1

dcmtk3.6.3

I used C++ to code the function of popen("findscu -v", "r"). I want to get the output message of findscu to save in file. But it only print to the console, i cannot save to file.

  1. //--verbose verbose mode, print processing details

FILE * fstream = popen("findscu --verbose", "r");
The output message of findscu is print to console.

char * p = fgets(buff, sizeof(buff), fstream);
p is NULL, and the buff is nothing.

  1. But if i use this code:
    //--help print this help text and exit
    FILE * fstream = popen("findscu --help", "r");
    It does not print to the console.

char * p = fgets(buff, sizeof(buff), fstream);
p is not NULL, and the buff has the output message.
That is what I want.

What is the differents of this two cases?
How to get the message from case 1?

thanks.

ubuntu18.04 C++ dcmtk3.6.3 findscu

//C++ dcmtk findscu
FILE * fstream = popen("findscu --verbose", "r");

char buff[10240] = {0};
char * p = fgets(buff, sizeof(buff), fstream);

cout <<  buff << endl;

I expect get output info from the buff, not from the console. Case 2 is what i want. Case 1 is what i dont want.

0 Answers0