ios - Correct usage of NMSSH -
when session created, shell started , commands written: no responses recieved , callback methods buffer never called, did miss?:
(executing 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; }
pty mode needs enabled, , there som issues in library (should fixed now)
Comments
Post a Comment