A : java 调用shell脚本的问题。我该怎么写 Process proc = Runtime.getRuntime().exec("/bin/sh run.sh stop"); 其中run.sh 是我写的一个启动和停止一个java的程序。 这样写对吗?我运行的时候一直有错 Q:奇怪,为什么你要exec("/bin/sh run.sh stop")? 不能直接exec("run.sh stop")吗? 在你的run.sh的第一行加入 #!/bin/sh 然后在shell下运行chmod a+x run.sh就可以把你的run.sh变成可执行文件了。 另外,要提醒的是你的j...
by lc0060305 - Linux文档专区 - 2007-03-02 17:00:19 阅读(4376) 回复(0)
情况如下: java调用一shell脚本,shell中,对iptables命令,用来打开或者关闭服务器端口, 开发阶段,一切都正常,直到上线,也能正常运行 过了一个月左右的时间,系统在java调用shell这一模块时,出现问题如下: java调用shell成功,shell里面的echo等命令都是执行了的,且有返回结果 但shell中,iptables命令这一部分,却看不到执行效果(有可能iptables命令就没有执行,因为iptables -L后根本没有变化) 手动在SSH中,去执行对应的shell脚本(ro...
我要在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...
当我调用下面语句时成功 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的程序。 这样写对吗?我运行的时候一直有错。
先说一下我的环境 ubuntu11.04+jdk1.6.35+tomcat6.0.35 自己写了个java web小程序,点击一个button执行一个shell脚本,脚本中有一个用curl命令来模拟播放音频的动作,且需要有cert和key文件,现在的问题是我单独在/home/jason-huo/playback下执行是可以的,但是部署在tomcat下,点击web应用下点击button执行shell脚本到如下这步, downloadurl=`curl -s --cert RDSQA.cert.pem --key RDSQA.key.pem "https://secure-direct.rhapsod...