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

Yong Su 21 Reputation points
2021-09-11T20:22:09.117+00:00

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]@永爱不变 . ~/.zzz.sh"

So what is wrong with my c++ codes?

Thanks,

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,527 questions
Sysinternals
Sysinternals
Advanced system utilities to manage, troubleshoot, and diagnose Windows and Linux systems and applications.
1,087 questions
{count} votes