Python Forum
How to run python code in Java using remote SSH without py file using streams in Java - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to run python code in Java using remote SSH without py file using streams in Java (/thread-17336.html)



How to run python code in Java using remote SSH without py file using streams in Java - varanasipavankumar - Apr-07-2019

How to run python code in Java using remote SSH without py file using streams in Java?
How to pass arguments in such a case?

let's say I have to connect to a device using SSH. I get the code from the database instead of storing code in a file. Now I use Java Streams to run the code in exec mode all at once. I ask the user to give the output in a specified JSON format. In this scenario, I want to send arguments to the code. But I am not so sure how to do it.
More importantly, this has to work for non-Linux devices where python prompt might not be available but you can SSH to the CLI where you can run certain commands. In this case, you are not sure of the location to say for example, /usr/bin/python is where the code should be executed after connecting to the target device through SSH.
Here is the example code www.jcraft.com/jsch/examples/Exec.java.html but for me there is no such UI / user interaction. It has to be done at one go.