使用JSch时重命名命令不起作用

问题描述 投票:0回答:1

[尝试使用JSch API重命名文件/文件夹,因为Shell命令无法执行它们。 mkdir和rmdir运行正常。

JDK版本-11。

JSch版本-0.1.55。

任何线索都会受到赞赏。预先感谢。

使用以下代码。

ChannelExec execChannel = null;
        try {
          execChannel = (ChannelExec) session.openChannel("exec");
          execChannel.connect();
          execChannel.setCommand("rename dir1 dir2");
          execChannel.start();
        } catch (JSchException ex) {
          throw new IOException(ex);
        } finally {
          if (execChannel != null) {
            execChannel.disconnect();
          }
        }
java sftp jsch
1个回答
0
投票

如果您使用的是Jsch,我相信远程主机是一个类似Unix的系统。在Unix中没有命令rename。请改用mv

© www.soinside.com 2019 - 2024. All rights reserved.