Try to execute linux commands such as "chown", "chggrp" and so on.Note: Make sure your program is running with root's identity.

解决方案 »

  1.   

    Dureek:我对Linux不是很熟,能否提供你所说的那样一段SHELL程序。
      

  2.   

    1.通过JAVA的Runtime类执行shell 程序2.编辑shell,例如
    # shell begin
    chown myAccount $1
    chgrp myAccount $1
    # shell end其中$1就是命令行参数,这里应该是文件名。
    如果要改变一个目录下所有文件的权限可以加上参数 -R
    chown -R myAccount $1
    chgrp -R myAccount $13.编辑以后用chmod +x shell_file_name 加上可执行权限
      

  3.   

    You do not need shell script :)Sample:# ls -alF t
    -rwxr-xr-x   1 root     root           20 Apr  3 09:49 t*
    # chown dureek.admin t
    # ls -alF t
    -rwxr-xr-x   1 dureek   admin          20 Apr  3 09:49 t*
      

  4.   

    是呀,可以不用SHELL的,但Runtime类怎么用呢,给个例子吧。
      

  5.   

    import java.io.BufferedReader;
    import java.io.InputStreamReader;public class ExecTest {
            public static void main(String[] args) {
                    StringBuffer cmd = new StringBuffer();                if ((args != null) && (args.length > 0)) {
                            for (int i=0; i<args.length; i++)
                                    cmd.append(args[i]).append(' ');
                    } else {
                            System.out.println("You forgot to specify parameters ;]");
                            System.exit(1);
                    }                try {
                            Process proc = Runtime.getRuntime().exec(cmd.toString())
    ;
                            BufferedReader br = new BufferedReader(new InputStreamRe
    ader(proc.getInputStream()));
                            String s = null;
                            while ((s = br.readLine()) != null) {
                                    System.out.println(s);
                            }
                    } catch (Exception e) {
                            e.printStackTrace();
                    }        }
    }
      

  6.   

    And try:# ls -alF ExecTest*
    -rw-r--r--   1 root     root         1269 May 29 10:58 ExecTest.class
    -rw-r--r--   1 root     root          781 May 29 10:58 ExecTest.java
    # java ExecTest /bin/chown nobody.nobody ExecTest.class
    # ls -alF
    -rw-r--r--   1 nobody   nobody       1269 May 29 10:58 ExecTest.class
    -rw-r--r--   1 root     root          781 May 29 10:58 ExecTest.java
      

  7.   

    麻烦Dureek,再写个Runtime在JSP中的例子。
      

  8.   

    Stop asking like a kid, do something meaning.
    I believe you can solve it perfectly by yourself =)* If these words made you feeling unhappy, I apologize ... 
      

  9.   

    Dureek非常感谢你的帮助,能交个朋友吗?(EMAIL OR OICQ)
    MY OICQ:446065
      

  10.   

    oke it's my pleasure :)oicq: 2043462
    mail: [email protected]