How to connect Remote Linux server using Sikuli with Python Code

Asked by Karishma

Hello, I am new to sikuli. I want to connect to Remote Linux server and execute some Linux command from Sikuli.
For this purpose I tried below Python code. That runs fine on the Python terminal that uses Python interpreter.

import paramiko
!(sys.executable} --version
host = 'IP Address'
user = '****'
pwd = '********'
c = Client(host, username=user, password=pwd, encrypt=False)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=host, username=user, password=pwd)
shell = ssh.invoke_shell()

After that I put the same code in Sikuli. Also stored the Paramiko package folder at below path and executed from Sikuli: C:\Users\MY_USER\AppData\Roaming\Sikulix\Lib

But it is throwing Import Paramiko Errors. As I go through some blogs I understand that,
Sikuli is based on Jython, not standard Python. Perhaps Python terminal uses Python interpreter to run the code,
but Sikuli IDE uses Jython interpreter, and that might be the reason why it does not see Paramiko module and cannot run it.

Is there any other way to achieve this?

Thanks in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

Paramiko cannot be used in Jython (and hence SikuliX) due to native library components, that are only available/accesible in native Python.

You might delegate the execution via SubProcess to a native Python execution.

Revision history for this message
Karishma (karishma123) said :
#2

Thanks RaiMan, that solved my question.