Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

problem with runtime and exec

vics0vics0 Posts: 2Member
Hello.
I want use 'wget' command from my Java application
for 'wget' i created command as String type.
Here is it

[code]String url_str=wget --post-data "year=2009&month=08&day=01&time=0&profile=1&start=0&stop=1000&step=50&par=&format=0&vars=01&vars=02" http://testsite.com/cgi/script.cgi -O /home/user/test_wget.txt
[/code]

then i use it in exec method

[code]

...
try{
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(url_str);
p.waitFor();
BufferedReader r = new BufferedReader(
new InputStreamReader(p.getErrorStream()));
String s;
while ((s = r.readLine())!=null) {
System.out.println( s );
}
r.close();
}
catch (IOException e){
// TODO Auto-generated catch block
e.printStackTrace();
}

catch ( InterruptedException e ) {
e.printStackTrace();
}
[/code]

after running the file test_wget.txt hold
[code]Model Error
Wrong key: not alpha/numerical characters[/code]

however, if i use my url_str from Linux command line
test_wget.txt is hold usefull data.

So, how working correct with wget from Java application?


Thanks for any replys
Sign In or Register to comment.