Data flow via NMSSH

Hi I want to develop an SSH application for OSX and I was looking at NMSSH which is built on libssh2. How can I handle the following use case:

The application user sends a ping command to the server. => result continuous reactions

The NMSSH approach sends a command to get a response and puts this in an NSString, see below. But how can I handle a case like ping where the response goes on and on. Do I need to use a different SSH package for this function?

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

      

0


source to share


1 answer


The correct answer is to use the library wrapper functionality in conjunction with the channel delegate callback methods. Some problems were found in lib but fixed as issue # 20



+2


source







All Articles