sending command from remote pc using paramiko

asked 2021-06-22 07:13:03 -0500

navid gravatar image

updated 2021-06-22 07:14:54 -0500


I am using a robot that is connected to a remote pc using localhost. I have used the Paramiko library to send commands from remote pc to my robot. I want to publish a number on /activate topic like this:

rostopic pub /activate std_msgs/Int16 "data: 1"

I have written the following code:

import paramiko
host = ""
port = 22
username = "robot"
password = "xxx"
command = "rostopic pub /activate std_msgs/Int16 'data: 1'"
ssh = paramiko.SSHClient()
ssh.connect(host, port, username, password)
stdin, stdout, stderr = ssh.exec_command(command)

My connection works because the same command works using SSH in the terminal or even PuTTY. But using Paramico I see no results in my robot.

edit retag flag offensive close merge delete