Re: running linux cmd in servlet/jsp

Sam Seaver <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
We've had a similar thing before, and I think it could well be the '|'
symbol. which is a shell construct, i believe.  Thus you'd need to actually
run a shell script that contains the full command you're trying to run,
instead of trying to get the '|' to work directly...


>Hi all,
>
>I would like to grep my linux MAC address, the command to run under linux
>should be like this
>ifconfig eth1 | grep HWaddr | awk '{print $5; }'
>
>Therefore i wrote it like below...
>
>But it failed.....
>
>Anyone can help?? Thanks.
>
>Regards
>KL
>
>*********************************
>   Process proc1=null;
>   Runtime rt1 = Runtime.getRuntime();
>
>   proc1 = rt1.exec("/sbin/ifconfig eth1 | grep HWaddr | awk '{print $5; }'
>");
>
>   BufferedReader result = new BufferedReader(new
>InputStreamReader(proc1.getInputStream()));
>   BufferedReader error = new BufferedReader(new
>InputStreamReader(proc1.getErrorStream()));
>
>   String str_result = null;
>   String str_error = null;
>
>   while ( ( str_result = result.readLine()) != null)
>   {
>    out.println(str_result);
>   }
>
>   while ( ( str_error = error.readLine()) != null)
>   {
>    out.println(str_error);
>   }
>*********************************
>
>
>
>
>Best regards,
>KL OOI
>Senior Software Engineer
>iBridge Capital Technology Solutions Limited
>
>General: (604)818-0988
>Fax: (604)818-0698
>DID: (604)818-0618
>Mobile: (6012)421-7772
>Email: [email protected]
>URL: www.ibridgecapital.com


_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.