QProcess doesn't show any output when it runs rsync

654 Views Asked by At

I start rsync in QProcess. My process runs fine (in its own terminal) if I use QProcess::startDetached() but nothing happens if I start it with QProcess:start(). The problem seems to be that QProcess can't apparently read messages from rsync and write it to the output window.

I have connect this signal in constructor.

MainWindow::~MainWindow()
{
    process = new QProcess(this);

    connect( process, SIGNAL(readyReadStandardOutput()), this, SLOT(onReadyReadStandardOutput() ) );
}

Later on button clicked I call:

void MainWindow::onButton1Clicked()
{
    process->start("rsync -a [email protected]:/path/ /rsync_folder");

    //process->start("ping 10.0.0.01"); // this works for testing and I see output but not the above.
}

When rsync starts, it prints a message and ask for password..none of it is received by my QProcess but the ping message are received..what could be possibly wrong here?

The above grieving line also works directly on windows 7 command line but it just doesn't seem to show any progress in QProcess.

Update

Here is how I displaying the output.

void MainWindow::onReadyReadStandardOutput()
{
    qDebug() << process->readAllStandardOutput();
}
2

There are 2 best solutions below

3
On

http://doc.qt.io/qt-5/qprocess.html#communicating-via-channels

Did you remember to link to and check the standard error channel?

http://doc.qt.io/qt-5/qprocess.html#readAllStandardError

That has fixed it for me in the past for some QProcesses I have started.

Another way I've done it, is to use QProcess::startDetached();

Hope that helps.

0
On

My research shows that rsync probably behaves like scp which accordingly this answer doesn't generate output when it is redirected.