scp does download all files when embeded in a QProcess
-
Hello, my code runs on Windows and has to download files from a remote directory. To do so, I use a command like
scp user@host:/path/to/folder/* /my/local/directory
It works as expected (all files are downloaded) when I run this command in the terminal. But when I try to use this command in a QProcess, it downloads only a few files (not all) and stop downloading the remaining files.
The QProcess does not emit any error or message.
Here is the simplified code relative to QProcess (I do not add the code that manages errors)
QProcess process; process.start("C:\\Windows\\System32\\OpenSSH\\scp.exe", QStringList("user@host:/path/to/folder/*", "/my/local/directory"));
Do you have any idea of what could happen?
-
You should wait until the process has finished: https://doc.qt.io/qt-6/qprocess.html#waitForFinished - or even better, use signals and slots and let the QProcess run asynchronously to not block the ui in between.
-
@odelaune: And just to add to @Christian-Ehrlicher: if the
QProcess
is a stack variable, it is destroyed when going out of scope and therefore the process stops. You will need to make it a member variable. -