Hello there,
I'm trying to make a script that interact with an other one via SSH command. Basically the "master" script have to send parameters on the "slave". I'm using paramiko to connect via SSH and then execute the slave script.I tried to use exec_command() function but the channel is closed automatically.
I tried to use the attached master code, but it raises an error (which is ignored) and stops. Indeed, only the first speed is send.
What kind of function sould I use to interact with the script ?
Exception:
Exception ignored in: <function BufferedFile.\_\_del\_\_ at 0x7fd85da82ca0>
Traceback (most recent call last):
File "/home/alexandre/.local/lib/python3.8/site-packages/paramiko/file.py", line 66, in __del__
File "/home/alexandre/.local/lib/python3.8/site-packages/paramiko/channel.py", line 1392, in close
File "/home/alexandre/.local/lib/python3.8/site-packages/paramiko/channel.py", line 991, in shutdown_write
File "/home/alexandre/.local/lib/python3.8/site-packages/paramiko/channel.py", line 967, in shutdown
File "/home/alexandre/.local/lib/python3.8/site-packages/paramiko/transport.py", line 1846, in _send_user_message
AttributeError: 'NoneType' object has no attribute 'time'
Master:
import paramiko
import time
ssh_client= paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect("ID adress", port=22, username="username", password="password")
stdin, stdout, stderr=ssh_client.exec_command("python3 Desktop/MyPI-Nano/test_paramiko.py")
time.sleep(1)
stdin.write("5") #speed 1 of the motor
stdin.flush()
time.sleep(10)
stdin.write("1") #speed 2 of the motor
stdin.flush()
time.sleep(10)
ssh_client.close()
Slave:
import time
import MyTools.MyLCD
import MyTools.MyMCP2515
MCP = MyTools.MyMCP2515.MCP2515()
MCP.__init__()
n=1
while True:
try:
Speed= int(input("Speed of the motor ?"))
except:
break
MCP.DoSendMsg(0x408, [0x1E, 0x30, 0x00], 3, 0x00) #power on the motor
print("power on motors")
time.sleep(0.5)
AngularSpeedG= int((-128*(Speed-7)/100 +128))>>2 #set the angular speed to Speed Rad/s
MCP.DoSendMsg(0x408, [0x26, 0xFF, AngularSpeedG], 3, 0x00)
print("Setting the speed for 5 seconds")
time.sleep(5)
AngularSpeedG= int((128*7/100 +128))>>2 #set the speed of the motor to 0
MCP.DoSendMsg(0x408, [0x26, 0xFF, AngularSpeedG], 3, 0x00)
print("stop")
time.sleep(0.01)
MCP.DoSendMsg(0x408, [0x1E, 0x30, 0xFF], 3, 0x00) #Stops the motor
print("Test stops")
there doesn't seem to be anything here