Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] How to write commands in gnome-terminal using QProcess??
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
qprocess
3 Posts 2 Posters 2.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Press
    wrote on last edited by Press
    #1

    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?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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();
      
      P 1 Reply Last reply
      0
      • mrjjM mrjj

        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();
        
        P Offline
        P Offline
        Press
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved