diff options
| author | Niklas Goby | 2011-03-10 22:44:25 +0100 |
|---|---|---|
| committer | Niklas Goby | 2011-03-10 22:44:25 +0100 |
| commit | bdafe6106b6ffade1b364087da6dab0feee35d0c (patch) | |
| tree | ee414d748b71953e1927306f6965b44850bf6e60 | |
| parent | collect script output function works (diff) | |
| download | fbgui-bdafe6106b6ffade1b364087da6dab0feee35d0c.tar.gz fbgui-bdafe6106b6ffade1b364087da6dab0feee35d0c.tar.xz fbgui-bdafe6106b6ffade1b364087da6dab0feee35d0c.zip | |
some changes pwd command doesn't work
| -rw-r--r-- | src/sysInfo.cpp | 18 | ||||
| -rw-r--r-- | src/sysInfo.h | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/sysInfo.cpp b/src/sysInfo.cpp index 929b45d..f17f42b 100644 --- a/src/sysInfo.cpp +++ b/src/sysInfo.cpp @@ -25,8 +25,6 @@ QString sysInfo::getInfo(QString& infoName){ return getAllInfos(); else if (infoName == QString("json")) return getNames(); - else if (infoName == QString("script")) - return getPrcOutP2(); // still here? return "info_error"; } @@ -83,6 +81,8 @@ QString sysInfo::getAllInfos(){ QVariantMap infos; infos.insert("mac", getMACAddress()); infos.insert("ip", getIPAddress()); + infos.insert("whoami", getScriptOutput("whoami")); + //infos.insert("pwd", getScriptOutput("pwd")); //QJson::Serializer serializer; QByteArray json = serializer.serialize(infos); @@ -90,10 +90,11 @@ QString sysInfo::getAllInfos(){ if (debug) qDebug() << json; return json; } -// -QString sysInfo::getPrcOutP2() +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +QString sysInfo::getScriptOutput(QString cmd) { - QString cmd = "echo test"; QProcess *process = new QProcess(); qDebug()<<"try to open: "<<cmd; process->start(cmd, QIODevice::ReadOnly); @@ -101,7 +102,7 @@ QString sysInfo::getPrcOutP2() if (!process->waitForStarted() ) qDebug()<<"process couldn't get opened"; - QStringList output; + QString output; process->waitForFinished(); QTextStream *txt_stream = new QTextStream(process); @@ -110,11 +111,10 @@ QString sysInfo::getPrcOutP2() { qDebug()<<"read output: "; QString tmp_str = txt_stream->readLine(); - output.append(tmp_str); + output += tmp_str; qDebug()<<tmp_str; } - qDebug()<<"process finished: "; - return ""; + return output; } diff --git a/src/sysInfo.h b/src/sysInfo.h index dac75e8..936f517 100644 --- a/src/sysInfo.h +++ b/src/sysInfo.h @@ -19,7 +19,7 @@ class sysInfo { QString getMACAddress(); QString getIPAddress(); QString getAllInfos(); - QString getPrcOutP2(); + QString getScriptOutput(QString cmd); }; #endif // SYSTEMINFO_H |
