没有例外,Command也没有根据提到的命令做任何工作。这里没有创建目录的权限,目录也没有创建。请给出您的建议。JSCH setCommand不起作用
更新: channelexe.getExitStatus增加,但问题是,它提供了-1,这个又是什么意思?我不知道如何找到一些解释,为什么命令没有做它的工作(更新777模式fileDir1)。
String depDir = "/usr/local/FTPReceive/DEPLOYED/fileDir1";
log.info("updateDepositedFilePermission ........ starts");
Session session = new FTPComponent().getSession("");
Channel channel = null;
ChannelSftp channelSftp = null;
try
{
session.connect();
System.out.println("session is alive:" + session.isConnected());
channel = session.openChannel("sftp");
channel.connect();
channelSftp = (ChannelSftp) channel;
ChannelExec channelexe = (ChannelExec) session.openChannel("exec");
channelexe.setCommand("chmod 777 -R " + depDir);
channelexe.connect();
System.out.println("channelexe.getExitStatus:"+channelexe.getExitStatus());
}
catch (Exception e1)
{
e1.printStackTrace();
System.out.println("Manual Exception in updateDepositedFilePermission:" + CommonUtil.getExceptionString(e1));
}
谢谢channelexe.getErrStream()有助于获得完整的跟踪。 – sunleo