The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

get terminal value back to ide?

hi im using ubuntu an if i run the command
wget http://ipecho.net/plain -O - -q ; echo
then my external ip is displayed in the terminal but if i run this with runtime... in java how do i get the value back to java ? cant assigne it to string ,the toString() just give memery location and there are no other aplicable methods does any know of a way cos all i can think of doing is writing it to a file and scanning it and damb it im sick of writing stuff to files

Re: get terminal value back to ide?

Originally Posted by copeg

Use the InputStream/OutputStream objects returned by the respective methods in the Process class returned by Runtime.exec to communicate with the process. And some further reading: When Runtime.exec() won't - JavaWorld

Re: get terminal value back to ide?

Just wondering, but is there some reason why you are using wget?

wget is a commandline/console tool for reading what servers produce when you hit them with a url. Consider wget a "square peg" and - as the JavaWorld article suggests - a Java application is something of a "round hole". Using wget from within a Java application involves all sorts of mucking about with streams (and the exceptions they might cause). But Java has all sorts of perfectly good ("round peg") networking classes and methods that could be used to directly get the text that http://ipecho.net/plain returns.

Re: get terminal value back to ide?

Originally Posted by pbrockway2

Just wondering, but is there some reason why you are using wget?

wget is a commandline/console tool for reading what servers produce when you hit them with a url. Consider wget a "square peg" and - as the JavaWorld article suggests - a Java application is something of a "round hole". Using wget from within a Java application involves all sorts of mucking about with streams (and the exceptions they might cause). But Java has all sorts of perfectly good ("round peg") networking classes and methods that could be used to directly get the text that http://ipecho.net/plain returns.