简体   繁体   中英

QProcess doesn't show any output when it runs rsync

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 root@10.0.0.1:/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();
}

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.

我的研究表明,rsync的行为可能类似于scp,因此,该答案在重定向时不会生成输出。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM