由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - error of unix redirecting command called by java
相关主题
pipe & filter 问题what's wrong with this little jsp?
Help! (转载)怎么用Java实现telnet功能?
Re: Java里怎么调用unix下的command?Re: 有用netbeans的吗?
怎样在JBuilder里输入这样的command?Help with Tomcat for Eclipse v1.03
Unix: where to execute java program?where to execute java program?
cool JS/UIXTomcat JSP syntax error
what's the difference between java.exe and javaw.exejava EL 问题请教
Issue when running a unix command with Runtime.getRuntime.exec()How to redirect standard input in java
相关话题的讨论汇总
话题: users话题: command话题: test话题: java
进入Java版参与讨论
1 (共1页)
A******a
发帖数: 61
1
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.
g*****g
发帖数: 34805
2
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.

Z****e
发帖数: 2999
3
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.

z***h
发帖数: 405
4
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.

A******a
发帖数: 61
5
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.

1 (共1页)
进入Java版参与讨论
相关主题
How to redirect standard input in javaUnix: where to execute java program?
Question of POP&SMTP server connectioncool JS/UIX
Build web server and dispatcher?what's the difference between java.exe and javaw.exe
help on "call a unix command in java"Issue when running a unix command with Runtime.getRuntime.exec()
pipe & filter 问题what's wrong with this little jsp?
Help! (转载)怎么用Java实现telnet功能?
Re: Java里怎么调用unix下的command?Re: 有用netbeans的吗?
怎样在JBuilder里输入这样的command?Help with Tomcat for Eclipse v1.03
相关话题的讨论汇总
话题: users话题: command话题: test话题: java