PDA

View Full Version : Qt4/C++ - QProcess - bin/bash script that expects input



jimbo
23rd May 2015, 10:10
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


QObject::connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutput()));
QObject::connect(process, SIGNAL(readyReadStandardError()), this, SLOT(processOutput()));
process->start(myCommmands);

void myProg::processOutput()
{
myOutput = new ee_output("Script output", this);

myOutput->t1->setText("Standard output:\n");
myOutput->t1->append(process->readAllStandardOutput());
myOutput->t1->append("Standard Error:\n");
myOutput->t1->append(process->readAllStandardError());
}

This is the textbox display:
Standard output:

This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.

Standard Error:

This is the terminal output:
...$ sudo ./myScript.sh -w -f=/home/pi/myFiles/test9999.eep -t=24c256
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): _

anda_skoa
23rd May 2015, 14:02
If you do not get the question the program might not write it to its standard out/err but to the controlling terminal instead.

To check, run the command manually but divert its outputs to files. If the question still appears it is being written to the terminal



program > stdout.txt 2> stderr.txt


Cheers,
_

jimbo
23rd May 2015, 16:07
Hello,

Thanks for your reply.

I tried you suggestion and got:

cat stdout.txt
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
cat stderr.txt
Do you wish to continue? (yes/no): OK its being written to one of the files, doesn't show in the textBox.

Regards