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

Yong Su 21 Reputation points

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);  


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

So what is wrong with my c++ codes?


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,604 questions
Advanced system utilities to manage, troubleshoot, and diagnose Windows and Linux systems and applications.
1,115 questions
{count} votes