简体   繁体   English

QProcess运行rsync时不显示任何输出

[英]QProcess doesn't show any output when it runs rsync

I start rsync in QProcess. 我在QProcess中启动rsync。 My process runs fine (in its own terminal) if I use QProcess::startDetached() but nothing happens if I start it with QProcess:start() . 我的过程中运行良好(在自己的终端),如果我用QProcess::startDetached()但如果我启动它什么也没有发生QProcess:start() The problem seems to be that QProcess can't apparently read messages from rsync and write it to the output window. 问题似乎是QProcess显然无法从rsync读取消息并将其写入输出窗口。

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? 当rsync启动时,它会打印一条消息并要求输入密码。.我的QProcess没有收到该消息,但收到了ping消息。.这可能是什么错误?

The above grieving line also works directly on windows 7 command line but it just doesn't seem to show any progress in QProcess. 上面的悲痛行也可以直接在Windows 7命令行上使用,但是似乎在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 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 http://doc.qt.io/qt-5/qprocess.html#readAllStandardError

That has fixed it for me in the past for some QProcesses I have started. 过去,对于我已经启动的一些QProcess,这已经为我解决了。

Another way I've done it, is to use QProcess::startDetached(); 我完成此操作的另一种方法是使用QProcess::startDetached();

Hope that helps. 希望能有所帮助。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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