[Ubuntu] how to run docker and redirect the output of docker using qt qprocess?
-
I want to run several commands and scripts in docker using qprocess. And redirecting the output of docker to qplaintext.But there is no result. Looking for help ! So how to run docker and redirect the output ????
Here is my command list:command_list_<<"sh docker/scripts/dev_into.sh"<<"cyber_recorder record -a";
docker/scripts/dev_into.sh is a script which get into my docker container
cyber_recorder is a command existed in this container
and using code following , my program can run command one by one;
void(QProcess:: *finished)(int) = &QProcess::finished; connect(this->process,finished,this,[=](){ if(!br->command_list().isEmpty()) { process->start(command_list_.at(0)); command_list_.removeFirst(); } });
Ps. Using qprocess to run
echo $USER
, the result is notmy hostname
,but$USER
. -
Hi,
Did you connect the QProcess::readyReadStandardOutput ? And use QProcess::readAllStandardOutput to read it ?
You might want to do as well for the error channel.
-
Please share your code. It's just guesswork at this point.
-
@corehaha said in [Ubuntu] how to run docker and redirect the output of docker using qt qprocess?:
command_list_<<"sh docker/scripts/dev_into.sh"<<"cyber_recorder record -a";
You may try this out.
QStringList arguments;
arguments<< "docker/scripts/dev_into.sh"
<<"cyber_recorder"
<< "record"
<< " -a";
process->start( QString( "/bin/sh" ), arguments );