Re: [問題] Runtime's problem in linux

看板java作者時間19年前 (2006/04/18 14:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
"../Src/siesta","<","h2o.fdf",">","h2o.siesta","&" 當你在 shell 底下輸入 ../Src/siesta < h2o.fdf > h2o.siesta 的時候, "shell 這個程式" 會去執行 ../Src/siesta, 以 h2o.fdf 為輸入並將輸出 導至 h2o.siesta 當你用 Runtime.exec({"../Src/siesta","<","h2o.fdf",">","h2o.siesta","&"}) 的時候, "<","h2o.fdf",">","h2o.siesta","&" 這些東西會被當成 "../Src/siesta" 的參數, 差別就在這. ※ 引述《hisahsi.bbs@ptt.cc (hisahsi)》之銘言: > 自己希望 " 使用Java來啟動 在linux的程式 " . > 當在執行程式時 , 需要讀入 input file 且產生 output file . > 所以 設定的command 如下: > String x[]={"../Src/siesta","<","h2o.fdf",">","h2o.siesta","&"} ; > 確定可以執行linux程式 , 但卻無法讀取到 input file 如 "h2o.fdf" . > (執行程式,檔案路徑位址正確) > 實在不瞭解為何讀取不到 input file ... !?!? >_<" > 因讀取不到 input file , 所以程式無法進行下一步驟. > 以上 . thanks . > ******************************************* > public class RuntimeExample_test{ > public static void main(String [] args) { > Runtime rt = Runtime.getRuntime(); > try { > String x[]={"../Src/siesta","<","h2o.fdf",">", > "h2o.siesta","&"}; > Process ps = rt.exec(x); > ps.waitFor(); > }catch(Exception e) { > e.printStackTrace(); > } > } > } > ******************************************** -- ▄▄▄▄▄▄▄ ▄▄▄▄ ▄▄▄▄▄▄ <telnet://bbs.cs.nctu.edu.tw> █▄▄▄▄█ █ ▄▄▄▄▄█ Player: Arjuna ▄█▄▄▄▄█ ▄▄▄█ █▄▄▄▄▄ From: alumni.csie.nctu.edu.tw ☆ 次世代BS2 ☆ 可申請個人板 150MB 超大相簿 http://pic.bs2.to 資訊人 250MB
文章代碼(AID): #14H82W00 (java)
文章代碼(AID): #14H82W00 (java)