Я установил сервер Python на своего робота, а также успешно создал сокет для робота.Все выглядит хорошо, но когда я хочу создать канал, у меня появляется сообщение об ошибке:
sending naocom/start.sh
W/System.err: bash: naocom/start.sh: Permission denied
, здесь я попытался установить соединение и запустить сервер Python с
public Map<String, Integer> sendSSHCommands(String[] aCommands, String... aInput){
// Connect to ssh server
Session vSession = connectSSH();
Map<String, Integer> vExitStatus = new HashMap<String, Integer>();
if( vSession != null){
// execute commands
for( int i=0; i < aCommands.length; i++ ){
String cmd = aCommands[i];
try{
// open channel
Channel vChannel = vSession.openChannel("naocom/start.sh");
ChannelExec vChannelExec = (ChannelExec) vChannel;
OutputStream vOutStream = vChannel.getOutputStream();
vChannelExec.setCommand(cmd);
vChannelExec.setOutputStream(System.out);
vChannelExec.setErrStream(System.err);
// connect
Log.i(TAG, "sending " + cmd);
vChannel.connect();
// get user information
SharedPreferences vPreferences = MainActivity.getPreferences();
// wait for command to complete
while( !vChannel.isClosed() ){
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
};
// add exit status
vExitStatus.put( cmd, vChannel.getExitStatus() );
vOutStream.close();
vChannel.disconnect();
} catch(JSchException e){
Log.e(TAG, e.getMessage());
} catch (IOException e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
}
}
// close ssh connection
closeSSH(vSession);
}
return vExitStatus;
}
когда я отлаживал свой код, я обнаружил, что он случился, когда start ();в Channel.java называется
public void connect() throws JSchException{
connect(0);
}
public void connect(int connectTimeout) throws JSchException{
this.connectTimeout=connectTimeout;
try{
sendChannelOpen();
start(); //here i have an error
}
catch(Exception e){
connected=false;
disconnect();
if(e instanceof JSchException)
throw (JSchException)e;
throw new JSchException(e.toString(), e);
}
}