Mac ターミナルでいくつかの外部コマンドを実行するために、いくつかの Java コードを作成します。ターミナルで実行する元のコマンドは
xpl-sender -c plugwise.basic -m xpl-cmnd command=livepower device=B83229 -w 3
コマンド文字列配列を使用すると、次のようになるため、本当に奇妙です。
Process ls = Runtime.getRuntime().exec(new String[]{
"/usr/local/bin/xpl-sender",
"-c", "plugwise.basic",
"-m", "xpl-cmnd",
"command=" + command,
"device=" + id});
「-w 3」がなければ正常に動作しますが、もちろんパラメータが不足しています。
しかし、私がこのように使用すると
Process ls = Runtime.getRuntime().exec(new String[]{
"/usr/local/bin/xpl-sender",
"-c", "plugwise.basic",
"-m", "xpl-cmnd",
"command=" + command,
"device=" + id,
"-w 3"});
最後に「-w 3」を付けると何も動かなくなり、コマンドが実行されていないように見えます。
そして、私がこのように使用すると
Process ls = Runtime.getRuntime().exec(new String[]{
"/usr/local/bin/xpl-sender",
"-c", "plugwise.basic",
"-m", "xpl-cmnd",
"command=" + command,
"device=" + id + " -w 3"});
最後に +" -w 3" を付けると、コマンドの実行に使用された perl プログラムが戻ります。
Illegal hexadecimal digit '-' ignored at /Library/Perl/5.12/xPL/Dock/Plugwise.pm line 964.
-w と 3 の間のスペースが原因でエラーが発生したよう
です。
どうもありがとうございました。