使用Java中的'watch'命令每隔X秒采样一次Linux命令

时间:2019-02-14 08:12:56

标签: java linux ssh

我正在尝试对文件夹进行采样以查看是否已创建所需的文件,因此我使用以下代码块每60秒对其进行采样:

 public static String command(Node node , long durationInSec, String command)
            throws Exception {
        RemoteCommandStrategy strategy = new RemoteCommandStrategy(node);
        Future<String> future = strategy.apply(new com.indeni.automation.terminal.Command(command) , durationInSec);
        return future.get();
    }

其中node是我的远程服务器,我正在使用的命令是:

"watch -n 60 find /usr/share/indeni/insight/ -name \"alert.csv\"";

但是当我执行此操作时,出现以下错误:

java.util.concurrent.ExecutionException: com.sun.mail.iap.CommandFailedException: Error opening terminal: unknown.


    at com.indeni.automation.terminal.CommandFuture.get(CommandFuture.java:43)
    at com.indeni.automation.terminal.CommandFuture.get(CommandFuture.java:12)
    at ssh.SshHelper.command(SshHelper.java:18)
    at ssh.SshHelper.command(SshHelper.java:11)
    at com.indeni.automation.helpers.CmdHelper$Remote$Command.execute(CmdHelper.java:109)
    at com.indeni.automation.tests.api.aws.InsightVerificationtTest.getFilesFromServerInsightFolder(InsightVerificationtTest.java:190)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
    at org.testng.TestRunner.privateRun(TestRunner.java:782)
    at org.testng.TestRunner.run(TestRunner.java:632)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    at org.testng.SuiteRunner.run(SuiteRunner.java:268)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    at org.testng.TestNG.run(TestNG.java:1064)
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
Caused by: com.sun.mail.iap.CommandFailedException: Error opening terminal: unknown.

0 个答案:

没有答案