C++ (Qt)CertAndKey GenerateCert(TypeClient type,unsigned int day,qint32 id){ if (QFile::exists("./SSL/CreateGrabberKey.sh")) { QStringList console; console << "konsole" << "xterm"; QString script = "./SSL/CreateGrabberKey.sh"; QStringList args; args << script; foreach (QString process, console) { qDebug()<<process; QProcess * p = new QProcess(); p->start(process,args); if (p->waitForStarted()) { break; } else { p->close(); qDebug()<<"no.."; delete p; } } }}
QString script = QApplication::applicationDirPath()+QDir::separator()+"SSL/CreateGrabberKey.sh";
C++ (Qt)CertAndKey GenerateCert(TypeClient type,unsigned int day,qint32 id){ if (QFile::exists("./SSL/CreateGrabberKey.sh")) { QStringList console; console << "konsole" << "xterm"; QString script = QApplication::applicationDirPath()+QDir::separator()+"SSL/CreateGrabberKey.sh %1 %2"; switch (type){ case Viewer:{ script = script.arg(QString::number(day),+"Viewer_"+QString::number(id)); break;} case Grabber:{ script = script.arg(QString::number(day),+"Grabber_"+QString::number(id)); break;} case Node: { script = script.arg(QString::number(day),+"Node_"+QString::number(id)); break;} default: { script = script.arg(QString::number(day),+"Undefined_"+QString::number(id)); break;} } qDebug()<<script; QStringList args; args << script; foreach (QString process, console) { qDebug()<<process; QProcess * p = new QProcess(); p->start(process,args); if (p->waitForStarted()) { p->waitForReadyRead(); qDebug() << p->readAllStandardOutput(); break; } else { p->close(); qDebug()<<"no.."; delete p; } } }}
"konsole cd /home/urivskay/QtProjects/RunScriptLinux/SSL/; ./CreateGrabberKey.sh 30 Viewer_2"
Ошибка сегментирования (core dumped)
C++ (Qt)CertAndKey GenerateCert(TypeClient type,unsigned int day,qint32 id){ QString base = QApplication::applicationDirPath()+"/SSL"; QString script; QStringList args; switch (type){ case Viewer: { args<<QString::number(day) << "Viewer_"+QString::number(id); script = base + "/CreateManagerKey.sh"; break; } case Grabber: { args<<QString::number(day) << "Grabber_"+QString::number(id); script = base + "/CreateGrabberKey.sh"; break; } case Node: { args<<QString::number(day) << "Node_"+QString::number(id); script = base + "/CreateNodeKey.sh"; break; } default: qCritical()<< "wtf?"; abort(); break; } qDebug()<<base << script << args; QProcess proc; proc.setWorkingDirectory(base); proc.start(script, args); int exitCode = -3; if(proc.waitForFinished(-1)) { exitCode = proc.exitCode(); } switch(exitCode) { case 0: qDebug()<< "generator script ok:" << exitCode; break; default: case -1: case -2: qCritical()<< "generator script failed:" << exitCode; qDebug() << "ERR" << proc.readAllStandardError(); qDebug() << "OUT" << proc.readAllStandardOutput(); break; }}
C++ (Qt) QStringList console; console << "konsole" << "xterm";