看板java
标 题Re: [问题] Runtime's problem in linux
发信站次世代BS2 (Tue Apr 18 13:57:05 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.ntu!news.ee.ttu!news.cis.nctu!BS2
"../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"
的参数, 差别就在这.
※ 引述《[email protected] (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