Call python3 script from java?

0 like 0 dislike
3 views
Use at home servcice to download torrents uTorrent for Linux.


He has one big (for me) drawback — it is not possible to determine in which folder you downloaded this particular torrent.


There is a script in python3 that helps to solve this problem.
Here is the thread of the discussion.

I wanted to write to him a small desktop face, in which you can enter an absolute path on the server where to save, choose the torrent that to download and enter your login and password for the server.


Faced with the fact that I don't know how to call pilinski script from Java.

Please help.
by | 3 views

3 Answers

0 like 0 dislike
And Runtime.exec() not suitable?
by
0 like 0 dislike
Try this:
\r
\r
Process p = Runtime.getRuntime().exec("sh script.py"); InputStream stdout = p.getInputStream(); InputStream stderr = p.getErrorStream(); The InputStreamReader isr = new an InputStreamReader(stdout); Isrerr an InputStreamReader = new an InputStreamReader(stderr); BufferedReader br = new BufferedReader(isr); BufferedReader brerr = new BufferedReader(isrerr); String line = null; System.out.println("OUTPUT:"); while ((line = br.readLine()) != null) System.out.println(line); System.out.println(); System.out.println("ERROR:"); while ((line = brerr.readLine()) != null) System.out.println(line); System.out.println(); p.waitFor(); 
by
0 like 0 dislike
Jython and JEPP do not support Python 3, so exec () is the best option.
The file is already registered shebang (#!/usr/bin/env python3), so that it can be run just as a script.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
4 answers
0 like 0 dislike
2 answers
asked Jun 3, 2019 by sdgdsgdgs89
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
28,875 users