PTY mode needs to be enabled, and there were som issues in the library (should be fixed now)
Pregunta
When a session is created, a shell is started and commands are written: no responses are recieved and the callback methods for the buffer is never called, what did i miss?:
(Executing a single command using channel:execute works)
-(void) createSessionWithAdress:(NSString*)address username:(NSString*)user password:(NSString*)pass{
session = [NMSSHSession connectToHost:address withUsername:user];
if (session.isConnected) {
[session authenticateByPassword:pass];
if (session.isAuthorized) {
NSError *err = nil;
session.channel.delegate = self;
//self.receiveView.text = [session.channel execute:@"ls" error:&err]; // works
[session.channel startShell:&err];
NSLog(@"Authentication succeeded");
}
}
}
- (void)channel:(NMSSHChannel *)channel didReadData:(NSString *)message{
NSLog(@"Read data!");
receiveView.text = [NSString stringWithFormat:@"%@ \n%@",receiveView.text,message];
}
- (void)channel:(NMSSHChannel *)channel didReadError:(NSString *)error{
receiveView.text = [NSString stringWithFormat:@"%@ \n%@",receiveView.text,error];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
NSLog(@"RETURN PRESSED");
NSError* err = nil;
bool commandSucess = [session.channel write:sendView.text error:&err];
[session.channel write:@"/n" error:&err];
if (commandSucess) {
NSLog(@"Command written successfully");
}else{
NSLog(@"Command not written successfully");
}
return YES;
}
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow