Results 1 to 3 of 3

Thread: Help with Qprocess and sending commands to terminal

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2017
    Qt products
    Qt4 Qt5

    Default Help with Qprocess and sending commands to terminal

    Hello Everyone,

    This is my first time posting, so bear with me as I get used to the format.

    I am using Qt 5.4.2 and red hat Linux 7.2

    1. I am creating a GUI that basically has some buttons to turn some relays on and off. (I'm done with the gui part)

    2 . Now this device is on the network and is user/password protected which I know both.

    3. I am creating a QProcess to communicate through Telnet and pass commands to turn on/off or enter credentials.

    This is what I am doing (please assume I call this in the main):

    void Example::process()
    QString prog = "telnet";
    QStringList arguments;
    arguments << "123.456.78.90" << "23"; // ip and port
    QProcess telnet;

    telnet.start(program, arguments);
    telnet.write("set 8 1");// which sets relay on


    qDebug() << telnet.readAllStardardOutput();

    Trying 123.456.78.90
    Connected to 123.456.78.90
    Escape Character is '^]'
    //-----------------------------end of output ------------

    Now if I put telnet.execute(...) instead of telnet.start(...)
    Trying 123.456.78.90
    Connected to 123.456.78.90
    Escape Character is '^]'

    Synacces Inc. Telnet Session V6.1
    //-----------------------------end of output ------------
    which is how it looks when I do that in the terminal, but program hangs waiting.

    Now my question is:

    How can I make it that it can receive more commands without closing that process? I don't want to close telnet because I have to tell it the ip and port again.
    Mainly notice that when I say telnet.write(command) it doesn't do anything. and I have put that line outside of the if and nothing.

    I would be running the terminal in the background while GUI is displaying buttons, but like I said GUI part is done.

    Thanks for any help and I hope it makes sense what I'm trying to accomplish
    Last edited by Oz; 22nd December 2017 at 21:19.

Similar Threads

  1. Sending command to terminal
    By dcasey627 in forum Newbie
    Replies: 3
    Last Post: 4th April 2016, 09:27
  2. Sending commands throught network
    By franco.amato in forum Newbie
    Replies: 1
    Last Post: 26th March 2012, 23:33
  3. Opening A Terminal using QProcess
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2011, 15:51
  4. Replies: 12
    Last Post: 11th September 2010, 02:39
  5. serial port printer sending commands, how?
    By triperzonak in forum Qt Programming
    Replies: 3
    Last Post: 6th April 2009, 15:51

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.