1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include "stdafx.h"
#include "process.h"
#include <iostream>
#include <limits>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// Connexion au serveur distant
char psBuffer[128];
FILE *pPipe;
if( (pPipe = _popen( "ssh2 login@XXX.XXX.XXX.XXX", "wt" )) == NULL ) {
exit( 1 );
}
/* Read pipe until end of file, or an error occurs. */
while(fgets(psBuffer, 128, pPipe))
{
printf(psBuffer);
}
/* Close pipe and print return value of pPipe. */
if (feof( pPipe))
{
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
}
else
{
printf( "Error: Failed to read the pipe to the end.\n");
}
//_spawnlp(_P_WAIT , "ssh2","ssh2","login@XXX.XXX.XXX.XXX", NULL );
// Fin du programme
cout << "Appuyez sur entrée pour continuer...";
cin.ignore( numeric_limits<streamsize>::max(), '\n' );
return 0;
} |
Partager