cs_stillfelil
Messages postés108Date d'inscriptionsamedi 31 juillet 2004StatutMembreDernière intervention12 septembre 2009
-
22 oct. 2007 à 12:44
cs_stillfelil
Messages postés108Date d'inscriptionsamedi 31 juillet 2004StatutMembreDernière intervention12 septembre 2009
-
22 oct. 2007 à 15:47
Bonjour
Je developpe sous Anjuta (je suis super nouveau en C++ sous Linux)
J'ai telechargé un package SSH Client qui s'appel NetSieben
j'ai du installer aussi libbotan1.5-dev
j'ai deazipé le source dans un sous dossier "sr"
et j'ai un main.cc qui fait appel au package
le fichier se compile sans probleme avec "g++ -g -c main.cc -o main.o"
mais l'orseque je lance la création de l'executable
j'ai plein d'erreurs
undefined reference to `ne7ssh::ne7ssh()'
undefined reference to `ne7ssh::setOptions(char const*, char const*)'
undefined reference to `ne7ssh::connectWithPassword(char const*, int, char const*, char const*, bool, int)'
peut etre que c'est un probleme de lien mais je suis vraiment novice en C/C++ et surtout sous linux
voila mon source (issu du site de NetSieben)
//-----------------------------------------------
#include
#include "sr/ne7ssh.h"
int main()
{
int channel1;
const char* result;
ne7ssh *_ssh = new ne7ssh();
std::cout << "Hello world" << std::endl;
// Set SSH connection options.
_ssh->setOptions ("blowfish-cbc", "hmac-md5");
// Initiate connection.
channel1 = _ssh->connectWithPassword ("10.12.12.1", 22, "user", "pass");
if (channel1 < 0)
{
printf ("Connection failed with last error: %s.\n\n", _ssh->errors()->pop());
delete _ssh;
return EXIT_FAILURE;
}
// Wait for bash prompt, or die in 5 seconds.
if (!_ssh->waitFor (channel1, " $", 5)) {
printf ("Failed while waiting for remote shell wiht last error: %s.\n\n", _ssh->errors()->pop (channel1));
_ssh->close(channel1);
delete _ssh;
return EXIT_FAILURE;
}
// Send "ls" command.
if (!_ssh->send ("sh run\n", channel1)) {
printf ("Could not send the command. Last error: %s.\n\n", _ssh->errors()->pop (channel1));
_ssh->close(channel1);
delete _ssh;
return EXIT_FAILURE;
}
// Wait for bash prompt, or die in 5 seconds
if (!_ssh->waitFor (channel1, " $#", 5)) {
printf ("Timeout while waiting for remote site.Last error: %s.\n\n", _ssh->errors()->pop (channel1));
_ssh->close(channel1);
delete _ssh;
return EXIT_FAILURE;
}
// Fetch recieved data.
result = _ssh->read (channel1);
if (!result)
printf ("No data received. Last error: %s.\n\n", _ssh->errors()->pop (channel1));
else
printf ("Received data:\n %s\n", result);
// Terminate connection by sending "exit" command.
_ssh->send ("exit\n", channel1);
// Destroy the instance.
delete _ssh;
return EXIT_SUCCESS;
}
//------------------------------
Si quelqu'un peut m'aider ;-)