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. Communicating with xterm
Qt 6.11 is out! See what's new in the release blog

Communicating with xterm

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.6k Views 1 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.
  • M Offline
    M Offline
    mkreddy477
    wrote on last edited by
    #1

    Hello all,
    This is my firs post in this forum and also I am new to Qt.
    I am developing an application in which i need to run certain commands on a emulated terminal.
    I am started to use "XTERM". I am able to open xterm but not able to send commands to it.
    Can any one please help me in this regard.

    @QString program = "xterm";
    QProcess *proc = new QProcess;
    proc->start(program);
    proc->waitForStarted();
    proc->write("ls\n");@

    i like to know weather is there any other terminal emulator to communicate efficiently.... ?

    Thanks in advance
    Murali krishna

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MrMNight
      wrote on last edited by
      #2

      No, you can't communicate with xterm (send something to its standart input). But you can communicate that way with "/bin/sh", for example:
      @
      QProcess proc;
      proc.start("/bin/sh");
      proc.waitForStarted();
      Q_FOREACH( QString cmd, QStringList() << "ls" << "date" << "echo test" )
      {
      proc.write((cmd + "\n").toLocal8Bit());
      proc.waitForReadyRead();
      qDebug() << proc.readAllStandardOutput().split('\n');
      }
      proc.write("exit\n");
      proc.waitForFinished();
      @
      or if you want you can run those program directly:
      @
      QProcess proc;
      proc.start("ls");
      proc.waitForFinished();
      qDebug() << proc.readAllStandardOutput();
      @

      P.S.: examples from "stackoverflow":http://stackoverflow.com/questions/15050462/qprocess-call-write-function-failure, but i have tested it, it works. Hope this helps.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mkreddy477
        wrote on last edited by
        #3

        Hello Thanks for the post.
        But my application need an emulated terminal to excute commands.

        Thanks and regards,
        Murali krishna.

        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