【问题标题】:Linux screen cmd execute not working?Linux屏幕命令执行不起作用?
【发布时间】:2015-07-22 09:17:54
【问题描述】:

我正在通过 java 运行它。

String cmd = "screen -dmS test -X eval \'stuff \"stop \\015\"\'";    

try {
    Runtime.getRuntime().exec(cmd);
} catch (IOException e) { e.printStackTrace();  }

它打印为

screen -dmS test -X eval 'stuff "stop\015"'

但是在我尝试运行它的屏幕上,我看到了这个:

-X: Missing ' quote.   AND     -X: Missing " quote.  

引号在哪里丢失?如果我通过控制台运行该命令,它工作正常。

【问题讨论】:

  • 当你的字符串中没有变量时,你为什么要使用+
  • 为了转义引号,它会准确地打印出我想要的样子,所以我不确定为什么会出现问题。
  • 你使用下面的String cmd = "screen -dmS test -X eval \'stuff \"stop \\015\"\'";
  • 打印效果也很好,但我仍然看到 -X: Missing " quote.
  • 它声称丢失了哪一个?在你的问题中,你说'但在你的回复中你说“

标签: java linux gnu-screen


【解决方案1】:

试试这个:-

String cmd[] = {"screen","-dmS","test","-X","eval", "'stuff","\"stop\\015\"'"};
try {
    Runtime.getRuntime().exec(cmd);
} catch (IOException e) { e.printStackTrace();  }

【讨论】:

  • 仍然说缺少报价。
  • 很好,我想我会找到另一种不使用屏幕的方法。
猜你喜欢
  • 2014-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多