作者AmosYang (LetMeGoogleThatForYou)
看板java
标题Re: [JSP ] call shell
时间Thu Apr 29 14:08:23 2010
※ 引述《fcshpeja (无名氏)》之铭言:
: 因为小弟需要做一个线上的系统
: 有用到JSP供使用者上传资料,再透过我的JAVA程式做运算
: 但是在JSP中使用
: String cmd = "sh /路径/档名.sh";
: Process p = Runtime.getRuntime().exec(cmd);
: 无法执行JAVA程式,但是可以写建立(删除)资料夹的shell
: 我也试着直接从java写call shell,去执行另一只JAVA程式,测试是没问题的
: 但是放到JSP就不会动,实在令人不解
: 请问有高手可以救援一下吗~~感激不尽
与其抓着「无法执行」四个字不放,不如把下面这些东西印出来看看…
http://java.sun.com/javase/6/docs/api/java/lang/Process.html
abstract int exitValue()
Returns the exit value for the subprocess.
abstract InputStream getErrorStream()
Gets the error stream of the subprocess.
abstract InputStream getInputStream()
Gets the input stream of the subprocess.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 65.87.177.87
编辑文章修正: 刚刚仔细一看,才发现之前贴错了…
之前贴的这个
abstract
OutputStream get
OutputStream()
Gets the output stream of the subprocess.
事实上传回来的是接着 STD
IN 的 OutputStream
这个
abstract
InputStream get
InputStream()
Gets the input stream of the subprocess.
才是接着 STD
OUT 的 InputStream
没仔细看清楚文件是我疏乎,然而这两个 method 的命名方式与 getErrorStream()
相比之下,也实在够呆的了…
※ 编辑: AmosYang 来自: 65.87.177.87 (04/29 21:22)
1F:推 godfat:this is not consistent.. XD 04/30 12:21
2F:→ AmosYang:XD 04/30 16:38