Results 1 to 3 of 3

Thread: Qt4/C++ - QProcess - bin/bash script that expects input

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qt4/C++ - QProcess - bin/bash script that expects input

    Hello,

    Qt4 / Linux

    I'm using QProcess to start a script (myScript.sh) that expects a response.
    At the moment I divert the output from the script to a QTextBox.
    I never get the yes/no question.
    There is more output from the script after the question.
    Is it possible to get the question to display? Answer it and get the rest of the output.
    I don't want to modify the script.

    Regards

    Qt Code:
    1. QObject::connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutput()));
    2. QObject::connect(process, SIGNAL(readyReadStandardError()), this, SLOT(processOutput()));
    3. process->start(myCommmands);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void myProg::processOutput()
    2. {
    3. myOutput = new ee_output("Script output", this);
    4.  
    5. myOutput->t1->setText("Standard output:\n");
    6. myOutput->t1->append(process->readAllStandardOutput());
    7. myOutput->t1->append("Standard Error:\n");
    8. myOutput->t1->append(process->readAllStandardError());
    9. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. This is the textbox display:
    2. Standard output:
    3.  
    4. This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
    5.  
    6. Standard Error:
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. This is the terminal output:
    2. ...$ sudo ./myScript.sh -w -f=/home/pi/myFiles/test9999.eep -t=24c256
    3. This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
    4. Do you wish to continue? (yes/no): _
    To copy to clipboard, switch view to plain text mode 
    Last edited by jimbo; 23rd May 2015 at 13:53.

Similar Threads

  1. Replies: 1
    Last Post: 18th November 2014, 18:18
  2. Running a bash script from resource (qrc) file
    By onamatic in forum Qt Programming
    Replies: 4
    Last Post: 3rd February 2012, 10:09
  3. Running an script using QProcess
    By DiegoTc in forum Newbie
    Replies: 1
    Last Post: 31st December 2010, 18:02
  4. QProcess + Bash
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 25th August 2009, 11:56
  5. QProcess Bash in Event Filter (Multiple Processes)
    By Arsenic in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2008, 08:42

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.