Redian新闻
>
error of unix redirecting command called by java
avatar
error of unix redirecting command called by java# Java - 爪哇娇娃
B*g
1
【 以下文字转载自 Database 讨论区 】
发信人: lakewest (lake), 信区: Database
标 题: ***CINAOUG/CINASSUG/PASS全球华人用户群新年讲座精品系列 -
发信站: BBS 未名空间站 (Sun Feb 17 18:26:16 2013, 美东)
新年好戏连台, 不可错过
**************请注意, 时间改动
Self service BI with Powerpivot by Derek
Wed, Feb 27, 2013
9:00 PM - 10:00 PM Eastern Time (Add to Calendar)
Please click here to join this meeting
http://www.anymeeting.com/CINASSUG1
Derek--BI Architect;
Over 8 years’ experience in database design, development, and
administration using a wide variety of tools and technologies. Having
focused on Business Intelligence using the SQL Server BI stack (SSAS, SSRS,
SSIS, Power-pivot, Semantic Model and Data Mining).
avatar
A*a
2
Process p = Runtime.getRuntime("cat /users/test/file1.txt /users/test/file2.
txt > /users/test/file3.txt").exec;
It reports an error like this:
cat: /users/test/file3.txt: No such file or directory
it seems it is the redirecting ">" symbol makes problem.
can anyone help here?! thanks.
avatar
g*g
3
The trick is to use a script to put down your command,
then use java to call that script.

file2.

【在 A******a 的大作中提到】
: Process p = Runtime.getRuntime("cat /users/test/file1.txt /users/test/file2.
: txt > /users/test/file3.txt").exec;
: It reports an error like this:
: cat: /users/test/file3.txt: No such file or directory
: it seems it is the redirecting ">" symbol makes problem.
: can anyone help here?! thanks.

avatar
Z*e
4
or use getOutputStream of Process class if more control is desired, but that
generally requires writing a thread to read the output

【在 g*****g 的大作中提到】
: The trick is to use a script to put down your command,
: then use java to call that script.
:
: file2.

avatar
z*h
5
should it be
Runtime.getRuntime().exec("cat ... ");
?

file2.

【在 A******a 的大作中提到】
: Process p = Runtime.getRuntime("cat /users/test/file1.txt /users/test/file2.
: txt > /users/test/file3.txt").exec;
: It reports an error like this:
: cat: /users/test/file3.txt: No such file or directory
: it seems it is the redirecting ">" symbol makes problem.
: can anyone help here?! thanks.

avatar
A*a
6
Thanks! yes, that is one solution. another one is here, need to write the
command as a string array and tell the shell dir clearly:
http://www.unix.com.ua/orelly/java-ent/servlet/ch13_04.htm
"
String[] command = { "/bin/csh", "-c", "finger | grep -v jhunter" };
The program Java executes is /bin/csh. csh is passed two arguments: -c,
which asks the shell to execute the next parameter, and finger | grep -v
jhunter, which is executed by the shell."

【在 g*****g 的大作中提到】
: The trick is to use a script to put down your command,
: then use java to call that script.
:
: file2.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。