all ,
Please help me with the following issue.
I have a linux device, to which I connect via SSH using PARAMIKO module in a python script.
The issue is that basically, if I send a command to the device, link "ping google.com" the output will be only shown after the command is finished ( in this case never) so I have to use "ping -n 2 google.com for example) and the output will be shown only after those 2 pings to google.com were completed.
The thing is that not all applications support a timeout parameter, and for example I am not able to use the "tail -f /file" because the tailing will never finish so the output will be never printed, nor to get other live traces which are partially printed by the device. The script is now used in this way.
elif action == "cmd":
cmd = command
(stdin, stdout, stderr) = ssh.exec_command(cmd)
out = stdout.readline()
if out:
print(out.replace("â", "").replace("ââ", "")) # only for case "systemctl --failed"
else:
print(stderr.read().decode('ISO-8859-1'))
else:
print("Your action: {} is invalid".format(action))
sys.exit(11)