It's not clear to me if you get an error or if you just get 
no result. So I can give just general hints:

- Use the complete path to ifconfig
  It should cause an exeption if you omit the pat and the 
  command is not found.

- The user that runs tomcat must have the right to call ifconfig
  It should cause an exeption if he hasn't.

- You have to read in loop:

            InputStream out=new BufferedInputStream(p.getInputStream());
            String mLine;
            while ((mLine = out.readLine()) != null) {
                ...
            }

- You have to wait until the command is ready after the read.

                p.waitFor();


> -----Original Message-----
> From: Philippe Valle [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 16, 2004 10:01 AM
> To: Tomcat Users List
> Subject: getRuntime().exec(...) root command problem
> 

> but for root command like 'ifconfig' i have nothing 

>     try
>     {
>       Process p=Runtime.getRuntime().exec("/bin/sh");
>       OutputStream in=p.getOutputStream();
>       in.write(cmd.getBytes());
>       in.flush();
>       InputStream out=new BufferedInputStream(p.getInputStream());
>       byte[] b=new byte[1024];
>       int    n=out.read(b);
>       for(i=0;i<n;i++) System.out.print((char)b[i]);
> 
>     }
>     catch(Exception ex) {
>     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to