I can run this command from the command line without any problems (script check is in progress):
c:/Python27/python ../feedvalidator/feedvalidator/src/demo.py https:
and from java if I left the URL parameter and just do:
String[] args1 = {"c:/Python27/python", "../feedvalidator/feedvalidator/src/demo.py" }; Runtime r = Runtime.getRuntime(); Process p = r.exec(args1);
It works great. If I use specific URLs for the parameter, for example:
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 great.
But if I use this particular URL https://das.dynalias.org:8080/das_core/das/2.16.840.1.113883.4.349/1012581676V377802/otherAdminData/careCoordinators , then the script just hangs (java is waiting for the process to complete). I'm not sure why it works from the command line for this url, but not from a java program. I tried adding quotes to surround the URL parameter, but that didn't work either. I do not see a single character in the URL, which, it seems to me, should be 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 and 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 to Find File or other OS error."); } String line = ""; while (br.ready()) { String str = br.readLine(); System.out.println(str); if (str.startsWith("line")) {
java
user994165 Dec 21 '11 at 20:14 2011-12-21 20:14
source share