request about scp command (QProcess) using qt
-
wrote on 8 Nov 2023, 07:09 last edited by
listArguments << "D:\\SVN\\Work\\test\\a.ini" << "user@192.168.1.250:/home/user/SW/";
Even though I entered it like this, it is the same.
The response from start comes immediately, but the readOutput function is not called. -
listArguments << "D:\\SVN\\Work\\test\\a.ini" << "user@192.168.1.250:/home/user/SW/";
Even though I entered it like this, it is the same.
The response from start comes immediately, but the readOutput function is not called.@hlowd said in request about scp command (QProcess) using qt:
but the readOutput function is not called
Probably because you're deleting m_process right after waitForFinished.
Are you sure scp.exe command is found?
Try with an absolute path to scp.exe to make sure it is actually found. -
listArguments << "D:\\SVN\\Work\\test\\a.ini" << "user@192.168.1.250:/home/user/SW/";
Even though I entered it like this, it is the same.
The response from start comes immediately, but the readOutput function is not called. -
The symptom is the same even if delete is not called.
If it is a command instruction rather than a code, the instruction will be executed normally.
The file is moved normally. (Windows -> Linux)@hlowd Again: try with absolute path to scp.exe
-
The symptom is the same even if delete is not called.
If it is a command instruction rather than a code, the instruction will be executed normally.
The file is moved normally. (Windows -> Linux)wrote on 8 Nov 2023, 07:44 last edited by hlowd 11 Aug 2023, 07:56@hlowd
There are files in that path.C:\Windows\WinSxS\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb scp.exe ssh-add.exe ssh-agent.exe ssh-keygen.exe
// new code
QString strParam = "C:\\Windows\\WinSxS\\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb\\scp.exe";
// error message
"CreateProcessW failed error:2 posix_spawn: No such file or directory"
-
@hlowd
There are files in that path.C:\Windows\WinSxS\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb scp.exe ssh-add.exe ssh-agent.exe ssh-keygen.exe
// new code
QString strParam = "C:\\Windows\\WinSxS\\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb\\scp.exe";
// error message
"CreateProcessW failed error:2 posix_spawn: No such file or directory"
wrote on 8 Nov 2023, 07:49 last edited by JonB 11 Aug 2023, 07:51@hlowd
If you want help on this, at least for my part, please make the effort to enclose your code blocks and literal extracts in the forums block quotes (</>
button) as we have asked several times. It does not require much effort on your side.By now you should be trying a command of
scp
, nothing else, no arguments, to verify that (a) it is found and can be run and (b) you can successfully read any output from it, e.g. presumably a "usage" message in this case. -
@hlowd
There are files in that path.C:\Windows\WinSxS\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb scp.exe ssh-add.exe ssh-agent.exe ssh-keygen.exe
// new code
QString strParam = "C:\\Windows\\WinSxS\\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb\\scp.exe";
// error message
"CreateProcessW failed error:2 posix_spawn: No such file or directory"
@hlowd said in request about scp command (QProcess) using qt:
Can I do it this way?
Yes, just try.
I would also execute scp using this absolute path in a terminal to make sure it works. -
@hlowd said in request about scp command (QProcess) using qt:
Can I do it this way?
Yes, just try.
I would also execute scp using this absolute path in a terminal to make sure it works.wrote on 8 Nov 2023, 08:00 last edited byThere are files in that path.
C:\Windows\WinSxS\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb scp.exe ssh-add.exe ssh-agent.exe ssh-keygen.exe
// new code
QString strParam = "C:\\Windows\\WinSxS\\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb\\scp.exe";
// error message
"CreateProcessW failed error:2 posix_spawn: No such file or directory"
The same error occurs in the command prompt.
-
There are files in that path.
C:\Windows\WinSxS\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb scp.exe ssh-add.exe ssh-agent.exe ssh-keygen.exe
// new code
QString strParam = "C:\\Windows\\WinSxS\\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb\\scp.exe";
// error message
"CreateProcessW failed error:2 posix_spawn: No such file or directory"
The same error occurs in the command prompt.
-
There are files in that path.
C:\Windows\WinSxS\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb scp.exe ssh-add.exe ssh-agent.exe ssh-keygen.exe
// new code
QString strParam = "C:\\Windows\\WinSxS\\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb\\scp.exe";
// error message
"CreateProcessW failed error:2 posix_spawn: No such file or directory"
The same error occurs in the command prompt.
@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 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
-
The scp.exe file exists in that path.
C:\Windows\System32\OpenSSH
I don't know why I couldn't find it using Explorer search.
@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 said in request about scp command (QProcess) using qt:
The scp.exe file exists in that path
Does it work with this path?
wrote on 15 Nov 2023, 08:10 last edited byThis post is deleted! -
wrote on 16 Nov 2023, 09:04 last edited by
@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.
-
@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.
wrote on 16 Nov 2023, 23:20 last edited byit 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();
-
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 Could you please read QProcess documentation?!
The way you're using QProcess is wrong: all parameters should be part of arguments list. And what about adding error handling as already suggested? -
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();
wrote on 17 Nov 2023, 06:28 last edited by@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..
-
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();
wrote on 17 Nov 2023, 07:47 last edited by JonB@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.
20/29