Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

RE: getRuntime().exec(...) root command problem

Sanjeev Kumar

2004-01-16

Replies:

Try
cmd="/sbin/ifconfig \n";

-----Original Message-----
From: Philippe Valle [mailto:pvalle@(protected)]
Sent: Friday, January 16, 2004 2:31 PM
To: Tomcat Users List
Subject: getRuntime().exec(...) root command problem



I want do do ipconfig on linux with exec java command.
When i do 'ls' for exemple is ok , but for root command like 'ifconfig'

i have nothing .

my code :
  ...................
  cmd="ls -l\n";
  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) {
  }
  .....................



I want just get MAC ADDRESS of my network device , there is another way
to do that ?


Thanks.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.