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

Hello,

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 = "xxx.xxx.x.x"
port = 22
username = "robot"
password = "xxx"
command = "rostopic pub /activate std_msgs/Int16 'data: 1'"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
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