$ sh -c "текст_скрипта"
$ sh -c "`cat << EOFтекст скриптаEOF`"
QString command = "sh -c \"`cat <<EOF\n" + scriptText + "\nEOF`\"";process->start(command);
stringList = "-c \"`cat <<EOF\n" + scriptText + "\nEOF`\"";process->start("su", stringList);
C++ (Qt) QString scriptText ="#!/bin/sh\n""\n""#\n""# Script to do someting\n""#\n""\n""echo \"do your work here\"\n""\n""exit 0\n"; QStringList stringList = QStringList() << "-c" << scriptText; p.start("sh", stringList); p.waitForFinished();
//-- test-qprocess, main.cpp:... QProcess *pProcess = new QProcess(); pProcess->start( QObject::tr( "/bin/sh" ), QStringList() << QObject::tr( "-c" ) << QObject::tr ( "echo $(pidof %1)" ).arg( argv[0]) ); if( pProcess->waitForStarted() ) { pProcess->waitForFinished(); qDebug( "%s", qPrintable( pProcess->readAllStandardOutput() ) ); }...
stringList = "-c \"`cat <<EOF\n" + scriptText + "\nEOF`\"";
QStringList() << "-c" << "cat <<EOF\n + scriptText + \nEOF";
QStringList() << "-c" << scriptText;
QStringList() << "-c" << "cat <<EOF\n" + scriptText + "\nEOF";