我想從Java發送下面的命令成功在linux從Java發送命令到Linux
此命令改變hylafax爲發送傳真 調制解調器,並運行此命令在Linux的shell 但是當它與Java運行如下:
modemcommand = "[email protected]";
InputStreamReader isr = null;
try {
isr = new InputStreamReader(Runtime.getRuntime().exec(modemcommand).getInputStream());
System.out.println("The Command : "+modemcommand+" is running successfull!");
} catch (IOException ex) {
System.out.println("The Command : "+modemcommand+" is not running successfull!");
System.out.println("Error on switch to modem : "+Modem+" :--> "+ex.toString());
System.out.println("--------------------------------------------------------------");
}
輸出爲:誤差= 2:沒有這樣的文件或目錄 有人能幫助我嗎?
這只是一個命令,當某些shell解釋時,所以你的意思是'sh FAXSERVER = ...';但是這可能仍然不能解決你的問題,因爲環境變量的作用域是shell進程(沒有全局設置)。 –