C++ (Qt)QProcess cgiStream; QStringList commands("./cgistream.sh"); cgiStream.start("/bin/sh", commands);cgiStream.waitToFinished(); qDebug() << cgiStream.readAllStandardOutput();
C++ (Qt)QProcess commandProc; commandProc.start("/bin/bash");commandProc.waitForStarted(3000); //123456 - пароль. \n - имитирует нажатие Enter.commandProc.write("echo 123456 | sudo -S rcnagios restart\n");commandProc.waitForFinished(4000); QByteArray ta = commandProc.readAll();
C++ (Qt) QProcess commandProc; QString commandLine; commandLine = "echo " + str + " | sudo -S rcnagios stop\n"; commandProc.start("/bin/bash"); commandProc.write(commandLine.toUtf8()); commandProc.waitForFinished(); qDebug() << commandProc.readAllStandardError(); qDebug() << commandProc.errorString(); qDebug() << commandProc.exitStatus(); qDebug() << commandProc.exitCode();