/* deviceData getDeviceData(string path) { struct deviceData hdd; size_t len = 0; //lenght of found line char * cLine = NULL; //found line string comand = ("./smartctl -a " + path); const char *cComand = comand.c_str(); FILE* outputfileSmart = popen(cComand, "r"); while ((getline(&cLine, &len, outputfileSmart)) != -1) { string line = string(cLine); cout << line << "XYZ\n"; string search ("Device Model:"); size_t found = line.find(search); if (found!=string::npos) { int lenght = line.length(); //lenght of line string str3 (":"); found = line.find(str3); cout << "Found1: " << found << endl; for(int i = (found+1); i < lenght; i++) { if(line[i] != ' ') { cout << i << endl; found = i; break; } } string model = line.substr (found, lenght); model = removeLastNewLine(model); cout << model << endl; return hdd; } } fclose(outputfileSmart); return hdd; } string removeLastNewLine(string s) { if (!s.empty() && s[s.length()-1] == '\n') { s.erase(s.length()-1); } return s; } */