1703582783

Remotely execute the "uname -a" command on a host provided via SSH and print the output


## the code ```py import subprocess import sys if len(sys.argv) !=2: exit("Usage: " + sys.argv[0] + " hostname") host = sys.argv[1] command = "uname -a" ssh = subprocess.Popen(["ssh", host, command], shell=False, stdout=subprocess.PIPE) result = ssh.stdout.readlines() error = ssh.stderr.readlines() if error: for err in error: sys.stderr.write("ERROR: {}\n".format(err)) if result: print(result) ``` Im going to create a series about Network with python. And of course we have a room here [https://chat-to.dev/chat?q=python-solutions](https://chat-to.dev/chat?q=python-solutions) to talk more about this language. Leave a comment here if you found it interesting or even if you have any errors. ;-)

(0) Comments