【问题标题】:stat returns `No such file or directory`, run under java execstat返回`没有这样的文件或目录`,在java exec下运行
【发布时间】:2020-05-23 07:48:16
【问题描述】:

我想在 Java 中调用stat,使用:

Runtime.getRuntime().exec("stat /*")

但总是得到退出代码 -1 并且:

stat: cannot stat `/*': No such file or directory

bash中运行stat /*就可以了,这样也可以:

Runtime.getRuntime().exec("stat /")

Java 中的stat /* 是否与 bash 中的行为不同?

【问题讨论】:

    标签: java bash exec stat


    【解决方案1】:

    stat /* 在命令行中工作,因为 shell 解释了*。 您应该尝试通过 bash 运行,例如,bash -c stat /*

    【讨论】:

      猜你喜欢
      • 2020-08-05
      • 1970-01-01
      • 2011-07-04
      • 2020-06-03
      • 2019-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多