How to Execute SCP command to transfer files to a target machine
-
@jsulm i can transfer file successfully to the target machine without errors. but wanted to redirect logs whatever (stdout,stderr, etc..,) to textedit. than
why should go for QProcess::ProcessError.@moyin Then check whether these connects actually were successful:
qDebug() << connect(&proc, SIGNAL(readyReadStandardError()), this, SLOT(readOutput())); qDebug() << connect(&proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
Place a qDebug() in your readOutput() to print something out to see whether the slot is actually called.
-
@moyin Then check whether these connects actually were successful:
qDebug() << connect(&proc, SIGNAL(readyReadStandardError()), this, SLOT(readOutput())); qDebug() << connect(&proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
Place a qDebug() in your readOutput() to print something out to see whether the slot is actually called.
-
@jsulm i mentioned u already that, while debug if i put break point at or in readoutput() that will stop at break point so it means slot is not getting called.
@moyin said in How to Execute SCP command to transfer files to a target machine:
while debug if i put break point at or in readoutput() that will stop at break point so it means slot is not getting called
sorry, I'm confused: if it stops at the break point inside readOutput() then it means that it is actually called.
Try this:
void Transfer::readOutput() { QString StdOut = proc.readAllStandardOutput(); //Reads standard output QString StdError = proc.readAllStandardError(); // Reads standard error qDebug() << StdOut; qDebug() << StdError; // ui->textEdit_Standard_output->setText(StdOut); // ui->textEdit_Standard_output->setText(StdError); ui->textEdit_Standard_output->setText(ui->textEdit_Standard_output->toPlainText() + StdOut + StdError); }
Do you see anything in Application Output?
-
@jsulm i mentioned u already that, while debug if i put break point at or in readoutput() that will stop at break point so it means slot is not getting called.
-
@moyin said in How to Execute SCP command to transfer files to a target machine:
proc.startDetached(command,params) ;
Hm, startDetached() is a static call, so attaching any signals to it won't work, right? Shouldn't start() be used here instead? Just a thought, I have not analysed this code in-depth.
-
@moyin Then check whether these connects actually were successful:
qDebug() << connect(&proc, SIGNAL(readyReadStandardError()), this, SLOT(readOutput())); qDebug() << connect(&proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
Place a qDebug() in your readOutput() to print something out to see whether the slot is actually called.
@jsulm its printing true for both
qDebug() << connect(&proc, SIGNAL(readyReadStandardError()), this, SLOT(readOutput())); qDebug() << connect(&proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));``` qDebug() in readOutput() is not printing any thing.
-
@jsulm its printing true for both
qDebug() << connect(&proc, SIGNAL(readyReadStandardError()), this, SLOT(readOutput())); qDebug() << connect(&proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));``` qDebug() in readOutput() is not printing any thing.
@moyin This is your problem:
proc.startDetached(command,params) ;
startDetached() is a static method! So you start your process, but it is not managed by the proc instance! Use start() instead:
proc.start(command, params);
-
@moyin This is your problem:
proc.startDetached(command,params) ;
startDetached() is a static method! So you start your process, but it is not managed by the proc instance! Use start() instead:
proc.start(command, params);
-
@moyin
I'm lost as to where you're at.But at least at one point you were told to use
QProcess::startDetached()
rather thanQProcess:start()
. I believe (untested by me, as usual, could be putting my neck on the line...) that you cannot properly redirect process input/output and/or get signals for input/output if you run the child process detached...? -
@moyin
I'm lost as to where you're at.But at least at one point you were told to use
QProcess::startDetached()
rather thanQProcess:start()
. I believe (untested by me, as usual, could be putting my neck on the line...) that you cannot properly redirect process input/output and/or get signals for input/output if you run the child process detached...? -
@JNBarchan This was already mentioned, but @moyin says that it isn't working even after changing to start().
There most be still something in the code, that's why I asked for the current code.@jsulm
OK, as long he is not tryingstartDetached
that's good...FWIW, I happen to just be working on my own Dialog which spawns a sub-process (
QProcess::start()
), gets its output via signals, and copies it into scrolling text widget, and it's all working fine for me. As one would expect!Purely BTW, given the command is an
scp
whose job is to copy the files, I wonder just what stdout/stderr output he is expecting? Has he informed us whether it's just the output that's missing/empty, or whether the whole command is not running in any case?? -
This post is deleted!