Linux
在JBoss 中用root启动web应用
在某个action中调用以下代码.运行后不起作用.也不报错.
Runtime rn = Runtime.getRuntime();
Process p = null;
commmon="su - oracle -c 'exp userid=jerry/welcome@oracle10 log=ExportDB.log buffer=8192000 compress=y grants=n file=/tmp/hello2006-08-11.dmp'";
p = rn.exec(commmon);
但在linxu#下运行su - oracle -c 'exp userid=jerry/welcome@oracle10 log=ExportDB.log buffer=8192000 compress=y grants=n file=/tmp/hello2006-08-11.dmp'则正常.
另window下
commmon="userid=jerry/welcome@oracle10 log=ExportDB.log buffer=8192000 compress=y grants=n file=/tmp/hello2006-08-11.dmp";
一切正常.
请问是什么原因.

解决方案 »

  1.   

    linux..那就不明白了。
    要是windows的不行还可以给你看看
      

  2.   

    public class BackupDB {
        public static void main(String[] args) {
            try {
                Runtime rn = Runtime.getRuntime();
                Process p = null;
                String commmon="echo 'dddd'>hello";
                p = rn.exec(commmon); 
                p.waitFor();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }}
    写了超简单的类,在linux中执行,也是没有反应.
      

  3.   

    InputStream errorIS = p.getErrorStream();
    InputStream is = p.getInputStream();
    然后把这两个InputStream的内容读出来打印一下看看
      

  4.   

    把你的数据库导入的语句写到一个shell里,然后去执行应该就可以了吧
      

  5.   

    问题与标题不符,这其实是如何调用LINUX命令行的问题。可以参考一下这个页面
    http://topic.csdn.net/t/20051008/16/4312657.html