I have such code
char USBpath[64]; void get_USB_SD_path(int device); bool checkUSB(void); void get_USB_SD_path(int device){ uint i; char * temp1; if((device == 0) || (device == 2)) { FILE *p2 = popen("df | grep -v /mnt | grep sd | cut -d'%' -f 2 | cut -d' ' -f 2","r"); memset(USBpath,'\0',64); fread(USBpath,sizeof(char),63,p2); pclose(p2); for(i=0;i<strlen(USBpath);i++) { if(USBpath[i]=='\n') USBpath[i]='\0'; } if(strlen(USBpath)>5) { if((USBpath[0]=='/')&&(USBpath[1]=='m')&&(USBpath[2]=='e')&&(USBpath[3]=='d')&&(USBpath[4]=='i')&&(USBpath[5]=='a')&&(USBpath[6]=='/')) { temp1 = USBpath + 12; // remove "/media/" } else { temp1 = USBpath + 7; // remove "/media/" } sprintf(USBname,"%s",temp1); } } if((device == 1) || (device == 2)) { FILE *p4 = popen("df | grep -v /mnt | grep nvm | cut -d'%' -f 2 | cut -d' ' -f 2","r"); memset(SDpath,'\0',64); fread(SDpath,sizeof(char),63,p4); pclose(p4); for(i=0;i<strlen(SDpath);i++) { if(SDpath[i]=='\n') SDpath[i]='\0'; } if(strlen(SDpath)>5) { if((SDpath[0]=='/')&&(SDpath[1]=='m')&&(SDpath[2]=='e')&&(SDpath[3]=='d')&&(SDpath[4]=='i')&&(SDpath[5]=='a')&&(SDpath[6]=='/')) { temp1 = SDpath + 12; // remove "/media/" } else { temp1 = SDpath + 7; // remove "/media/" } sprintf(SDname,"%s",temp1); } } } bool checkUSB(void) { int result=0; struct statfs usb; result = statfs(USBpath, &usb); if((USBpath == NULL) || result) { USB_mounted = false; //printf("140: no USB device USB path '%s' statfs = %d \n", USBpath, result); std::cout << "140: no USB device USB path '%s' statfs = %d" <<std::endl; return false; } else { switch(usb.f_type){ case 0xEF53: //ext2, ext3 USBfileSystem = 1; break; case 0x4d44: //fat USBfileSystem = 2; break; default: // unknown USBfileSystem = 0; break; } USB_mounted = true; } USBblockSizeKB = usb.f_bsize / 1024; USBfreeSpaceMB = (usb.f_bavail * USBblockSizeKB) / 1024; USBtotalSizeMB = (usb.f_blocks * USBblockSizeKB) / 1024; if(USBfreeSpaceMB < 0) return false; return true; } void test(){ FILE *p; char result[255]; int i=0; p = popen("rsync --info=progress2 %s/testfile100M %s/testfile100Mss\n", "r", USBpath, USBpath); //copy the same file to the same drive if(!p) { fprintf(stderr,"Error opening pipe.\n"); std::cout << ("Error opening pipe.\n") << std::endl; } while(fgets(result, 255, p)){ // std::cout << (result) << std::endl; } char name[100]; char name3[100]; char *name2; char wert[100]; char trennzeichen[] = "100\%"; name2 = strtok(result, trennzeichen); sprintf(name, "%s", name2); name2 = strtok(NULL, trennzeichen); sprintf(name3, "%s", name2); name2 = strtok(NULL, trennzeichen); sprintf(wert, "%s", name2); /* for(i=0;i<30;i++) { wert[i]=wert[i+2]; if(wert[i-1] == 'c') { wert[i] = '\0'; } } */ // std::cout << (name) << std::endl; std::cout << (name3) << std::endl; // std::cout << (wert) << std::endl; } gives p = popen("rsync --info=progress2 %s/testfile100M %s/testfile100Mss\n", "r", USBpath, USBpath); an error that caused too many arguments, although it is not.
cout, but I don’t even see Qt here. - ixSci