我用java调用一个shell命令,这个命令中包含有一个重定向, 但是调用完成以后,重定向的文件没有生成,为什么,怎么解决呢? 我试了一下 发现如果用重定向,用我下面的方法都不能产生重定向文件。 谢谢 =================java=================== String commands2 = "rwptoflow /opt/packet/110.23.117.251/2008-07-24/2008-07-24-14-01-13.out > /opt/packet/tmp/rwp.flow"; Process process = Runtime.getRuntime().exec ...
import java.io.*; //import java.lang.*; public class Tbat extends Object { public static int RunThis(String args) { Runtime rt = Runtime.getRuntime(); int rc = -1; try { Process p = rt.exec(args); int bufSize = 4096; BufferedInputStream bis = new BufferedInputStream(p.getInputStream(), bufSize); int len; byte buffer[] = new byte[bufSize]; //Echo back what the program spit out...
当我调用下面语句时成功 String command = "/bin/bash /opt/bin/ExportEventsDb.sh 07/01/2008 07/02/2008"; Process child = Runtime.getRuntime().exec(command); 但是当我想重定向时,即 String command = "/bin/bash /opt/bin/ExportEventsDb.sh 07/01/2008 07/02/2008 > aaa.txt"; Process child = Runtime.getRuntime().exec(command); 脚本似乎没有执行。 有知道的xdjm...
Process proc = Runtime.getRuntime().exec("/bin/sh run.sh stop"); 其中run.sh 是我写的一个启动和停止一个java的程序。 这样写对吗?我运行的时候一直有错。
我要在java中调用一个shell命令. 其中shell代码如下: ------------------------------------------------- #!/bin/bash # run command script # rc.sh FILE="$1" CMD="$2" # run command and output its PID $CMD & echo $! > $FILE wait # delete the PID /bin/rm -f $FILE ------------------------------------------------- 其中,$1就是个文件名,用于存储PID,$2是个命令,可以带参数,比如"du -c -B M" java中这样调用 ... Pr...
我要在java中调用一个shell命令. 其中shell代码如下: ------------------------------------------------- #!/bin/bash # run command script # rc.sh FILE="$1" CMD="$2" # run command and output its PID $CMD & echo $! > $FILE wait # delete the PID /bin/rm -f $FILE ------------------------------------------------- 其中,$1就是个文件名,用于存储PID,$2是个命令,可以带参数,比如"du -c -B M" java中这样调用 ... Pro...