Since I was doing QT development under linux, sometimes used auxiliary shell scripts, but requires QT run a shell script and get the results in today to share my skills, without further ado directly on the code:
Method // execute the shell or shell script instruction QString the Common :: executeLinuxCmd (QString strCmd) { The QProcess P; p.start ( "the bash", a QStringList () << "- C" << strCmd); p.waitForFinished () ; QString strResult p.readAllStandardOutput = (); return strResult; } // example QString strResult1 = executeLinuxCmd ( "the sudo /home/test.sh SH"); QString strResult2 = executeLinuxCmd ( "CAT / etc / hostname"); we according your business needs to deal with strResult1 and strResult2, I believe the code is very clear now! ! !