[SOLVED] How to write commands in gnome-terminal using QProcess??



  • I have coded the following lines. Only the gnome terminal is opening and the command i tried to write inside the terminal (for eg) "ls" is not working

    @QProcess proc;
    proc.start ("gnome-terminal");
    proc.waitForStarted();
    proc.write("ls\n");
    proc.waitForBytesWritten();
    proc.waitForFinished();@

    What am i supposed to do?


  • Qt Champions 2016

    HI and welcome
    Here is how one can run ping with parameters
    Hope it can give hint.

    QProcess pingProcess;
    QString exec = "ping";
    QStringList params;
    params << "-c" << "1" << IP;
    pingProcess.start(exec,params,QIODevice::ReadOnly);
    pingProcess.waitForFinished(-1);
    QString p_stdout = pingProcess.readAllStandardOutput();
    QString p_stderr = pingProcess.readAllStandardError();
    


  • @mrjj
    Ya got a hint...actually its working now..Thanks for the information :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.