Results 1 to 4 of 4

Thread: Sending command to terminal

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Sending command to terminal

    I am currently using Fedora 23 and QT 5.6. I am building a command for Hping3 and trying to send that command to the terminal and receive the results. I can get the terminal to open but I can not get it to receive any commands. I am very new to QT so my knowledge is minimal. I learned programming with Visual Basic so I understand logic but this syntax is killing me.

    Qt Code:
    1. //Sending the command to terminal
    2. QProcess proc;
    3. proc.start("/usr/bin/gnome-terminal");
    4.  
    5. proc.waitForStarted();
    6. proc.write("su");
    7. proc.write("ite");
    8. //proc.write(command);
    9. proc.waitForFinished();
    10.  
    11. QByteArray output = proc.readAll();
    12. proc.close();
    13. ui->dgvResults->setText(output);
    To copy to clipboard, switch view to plain text mode 

    I am trying to display in a QTextBrowser and Commented out that one write command because I am getting an error

    /home/itestudent/SeniorProject/frmmain.cpp:112: error: no matching function for call to 'QProcess::write(QString&)'
    proc.write(command);
    ^

    Command is declared at the top of the button push event
    QString command = "hping3 -S ";

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Sending command to terminal

    Why do you need the terminal?
    Why not just execute the command?

    Cheers,
    _

Similar Threads

  1. Execute command without terminal window
    By RolandHughes in forum Qt Programming
    Replies: 2
    Last Post: 17th June 2015, 09:38
  2. Replies: 12
    Last Post: 19th July 2012, 21:22
  3. Replies: 0
    Last Post: 17th August 2010, 12:37
  4. Replies: 7
    Last Post: 15th April 2007, 01:39
  5. call bash/terminal command with QT
    By myta212 in forum Newbie
    Replies: 1
    Last Post: 13th November 2006, 15:38

Tags for this Thread

Bookmarks

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.