Advertisement
safoura

Untitled

Nov 29th, 2011
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. try{
  2. Runtime r = Runtime.getRuntime();
  3. File dir=new File(".");
  4. File dir1=new File(".\\python\\a");
  5. System.out.println("Curr dir . : "+dir.getCanonicalPath());
  6. System.out.println("Curr dir .. : "+dir1.getCanonicalPath());
  7. p = r.exec(".\\python\\a\\a.exe",null,dir1);
  8. //p = r.exec("cmd /c c:\\python26\\python C:\\Users\\DevTech\\workspace\\callPython\\src\\a.py");
  9. //System.out.println("msg:"+msg);
  10. //sending the command arguments to python files(in the cases of "wait for" and "Repeat"
  11. // System.out.println("in pywedo"+msg);
  12.  
  13. OutputStream os = p.getOutputStream();
  14. msg+="\n";
  15. os.write( msg.getBytes() );
  16. os.flush();
  17. os.close();
  18. //11/10/2011
  19. //p.waitFor();
  20.  
  21. //p.waitFor();
  22. BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
  23. BufferedReader br1 = new BufferedReader(new InputStreamReader(p.getErrorStream()));
  24. String line = "";
  25. while ((line = br.readLine()) != null)
  26. {
  27. System.out.println("returned: from Manager: "+line);
  28. status=line;
  29. }
  30. String line1="";
  31. while ((line1 = br1.readLine()) != null)
  32. {
  33. System.out.println("returned error: from Manager: "+line1);
  34. status=line1;
  35. }
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement