From bdafe6106b6ffade1b364087da6dab0feee35d0c Mon Sep 17 00:00:00 2001 From: Niklas Goby Date: Thu, 10 Mar 2011 22:44:25 +0100 Subject: some changes pwd command doesn't work --- src/sysInfo.cpp | 18 +++++++++--------- src/sysInfo.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') 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: "<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()<