Domanda

Hi I want to develop an SSH application for OSX and i have been looking into NMSSH, which is built on libssh2. How can I handle the following use case:

The application user sends a ping command to the server. => the result is continious responses

NMSSH's approach is send a command get a response and put that in a NSString, see below. But how can i handle a case with for instance ping where the response goes on and on. Do I need to use another SSH package for this functionality?

NMSSHSession *session = [NMSSHSession connectToHost:@"127.0.0.1:22"
                                       withUsername:@"user"];

if (session.isConnected) {
    [session authenticateByPassword:@"pass"];

    if (session.isAuthorized) {
        NSLog(@"Authentication succeeded");
    }
}

NSError *error = nil;
NSString *response = [session.channel execute:@"ls -l /var/www/" error:&error];
NSLog(@"List of my sites: %@", response);

BOOL success = [session.channel uploadFile:@"~/index.html" to:@"/var/www/9muses.se/"];

[session disconnect];
È stato utile?

Soluzione

The correct answer is to use the shell functionality of the library in combination with the callback methods of channel delegate. Some issues were found in the lib but are fixed as of issue #20

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top