question

YongSu-3473 avatar image
0 Votes"
YongSu-3473 asked XiaopoYang-MSFT edited

Using VC++ code to call ssh.exe to link linux machine, return 255

Hi, experts,
I need to call ssh.exe from VS c++ codes to call a linux machine. I tried following from the Visual Studio 2013 c++ codes:
MyString sExeName("ssh");
MyString sHost;

  errno_t err = _set_errno(0);
  intptr_t t = _wspawnlp(_P_WAIT, sExeName.c_str(), sExeName.c_str(), sHost.c_str(), NULL);

_get_errno(&err);

ssh.exe is in my path: "C:\Program Files\OpenSSH-Win64" But I now get t = 255, without error, meaning that it already started call the ssh.exe, but didn't return 0. What does 255 means?

If I open the dos command prompt, and call the following line, it works fine:
"ssh [hostxxxx]@yyy . ~/.zzz.sh"

So what is wrong with my c++ codes?

Thanks,

c++windows-sysinternals-procmon
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


If the manual command has several arguments (separated by space), then you probably should pass the corresponding arguments to _wspawnlp too.

Also try a simpler function: system("ssh [hostxxxx]@yyy . ~/.zzz.sh").


0 Votes 0 ·

II did pass all the arguments, with NULL in the end.

0 Votes 0 ·

Well, from what I can see it appears that the SHost variable was not initialized with any parameters.

0 Votes 0 ·

If you are using a DOS command prompt then you are using a very old version of Windows. Use a command prompt in a current version of Windows instead of using a DOS command prompt.

0 Votes 0 ·

0 Answers