我已经在机器人上安装了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);
}
}