request about scp command (QProcess) using qt
-
@hlowd Did scp executable ever work for you in terminal? The path where it is located looks strange, don't know from where it comes. On my machine I have it here: c:\windows\System32\OpenSSH\scp.exe
You can check where your scp.exe is located using this command:
where scp
-
@hlowd said in request about scp command (QProcess) using qt:
The scp.exe file exists in that path
Does it work with this path?
-
@hlowd
This really should not be too difficult to diagnose, if you stick to what is suggested and report behaviour.First try both of
scp \full\path\to\scp
in a Command Prompt. I assume at least one "works", and produces a "usage" output message?
Whichever produces the message, now try from a Qt program
QProcess proc; proc.start("....."); // here try whichever worked in Command Prompt qDebug() << proc.waitForFinished(); qDebug() << proc.readAll();
and report output.
-
it works(data is output)
- output 1 : true
- output 2 : "\r\nWindows IP ....."
QProcess proc; proc.start("ipconfig /all"); qDebug() << "output 1 : " << proc.waitForFinished(); qDebug() << "output 2 : " << proc.readAll();
do not Working
- output 1 : false
- output 2 : ""
QProcess proc; proc.start("scp C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/"); qDebug() << "output 1 : " << proc.waitForFinished(); qDebug() << "output 2 : " << proc.readAll();
this is also do not working
- output 1 : false
- output 2 : ""
QProcess proc; proc.start("C:\\Windows\\System32\\OpenSSH\\scp.exe C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/"); qDebug() << "output 1 : " << proc.waitForFinished(); qDebug() << "output 2 : " << proc.readAll();
-
@hlowd said in request about scp command (QProcess) using qt:
proc.start("scp C:\Users\user\a.ini user@192.168.1.250:/home/user/SW/");
You need argument list for
QProcess
The whole statement instart
wont work.Here in your similar topic is an example by @ChrisW67 and me..
-
@hlowd
So, as I suspected, this shows you are not usingQProcess::start()
correctly. (It is also not the same as the code you posted in earlier, which was correct at one point.) Which is why I asked you to clarify this. Ifstart("scp", ...)
orstart("/path/to/scp", ...)
run the scp executable, and perhaps produce "usage" output you can capture, it shows that is working.Your other attempts should all indeed fail as you incorrectly try to pass arguments in the string which should be the executable. The example at https://doc.qt.io/qt-6/qprocess.html#running-a-process shows how to do this correctly. If you are on Qt 6.0+ there is a new method,
startCommand()
, which works the way you tried, if you really want to do it that way.