Java Runtime.exec() -


i can run command command line without problem (the validation script executes):

c:/python27/python ../feedvalidator/feedvalidator/src/demo.py https://das.dynalias.org:8080/das_core/das/2.16.840.1.113883.4.349/1012581676v377802/otheradmindata/carecoordinators  

and java if leave off url parameter , do:

string[] args1 = {"c:/python27/python", "../feedvalidator/feedvalidator/src/demo.py" }; runtime r = runtime.getruntime(); process p = r.exec(args1); 

it works fine. if use urls parameter such as:

string[] args1 = {"c:/python27/python", "../feedvalidator/feedvalidator/src/demo.py" , "http://www.intertwingly.net/blog/index.atom"}; // or  string[] args1 = {"c:/python27/python", "../feedvalidator/feedvalidator/src/demo.py" , "http://www.cnn.com"}; 

it works fine.

but if use particular url https://das.dynalias.org:8080/das_core/das/2.16.840.1.113883.4.349/1012581676v377802/otheradmindata/carecoordinators, script hangs (java waits process finish). i’m not sure why works command line url not java program. tried adding quotes surround url parameter didn’t work either. don’t see character in url think need escaped.

full code:

string urltovalidate = "https://das.dynalias.org:8080/das_core/das/2.16.840.1.113883.4.349/1012581676v377802/otheradmindata/carecoordinators";  string[] args1 = {"c:/python27/python", "c:/documents , settings/vhaiswcaldej/das_workspace/feedvalidator/feedvalidator/src/demo.py", urltovalidate }; system.out.println(args1[0] + " " + args1[1] + " " + args1[2]);  runtime r = runtime.getruntime(); process p = r.exec(args1); bufferedreader br = new bufferedreader(new inputstreamreader( p.getinputstream())); int returncode = p.waitfor();  system.out.println("python script or os return code: " + integer.tostring(returncode)); if (returncode >= 2) {     .out.println("os error: unable find file or other os error.");     }  string line = ""; while (br.ready()) {      string str = br.readline();      system.out.println(str);      if (str.startswith("line")) {      //todo: report error test tool.      //system.out.println("error!");      }      } 

you need drain output , error streams of process, or else block when executed program produces output.

from process documentation:

because native platforms provide limited buffer size standard input , output streams, failure promptly write input stream or read output stream of subprocess may cause subprocess block, , deadlock.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -