Hey All,
This is the Exact task i need to do with, Though i have tried this with python using the library paramiko,
i was unable to find the way for doing can anyone guide me.
Thanks,
Sri
Hey All,
This is the Exact task i need to do with, Though i have tried this with python using the library paramiko,
i was unable to find the way for doing can anyone guide me.
Thanks,
Sri
To run python externally, you need no libraries locally. You need them wherever python will run.
In Ignition, I would use java’s normal classes (starting with ProcessBuilder) to spawn your platform’s ssh
executable with suitable parameters (to connect to the remote system and launch your script), with a stream attached to the process’ stdout
. Parse/decode that stream to get your result.
Use SSH keys to avoid any prompts while connecting. I recommend arranging for the selected key to only allow running the target script. (A limitation applied to the corresponding line of authorized_keys
in the remote system.)
hi @pturmel can you give me any links for example.
Thanks
Sri
I have no sample I can share, sorry. Look at the man-page for ssh
and StackOverflow for ProcessBuilder
.
ProcessBuilder sample:
Thanks @PGriffith,
That worked Fine for me
Regards,
Sri
I tried running this:
from java.lang import ProcessBuilder, String
pb = ProcessBuilder([r"/usr/bin/pwd"])
process = pb.start()
output = String(process.getInputStream().readAllBytes())
print output
get this:
java.io.IOException: java.io.IOException: Cannot run program "/usr/bin/pwd": CreateProcess error=2, The system cannot find the file specified
Tried system.util.execute, same error. Actually I've been able to run whoami without an error using execute. So I'm not sure how to import the java into the python script in ignition.Thx,jake