Python Forum

Full Version: How to run local python script to remote machine without sending
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have created a python script on my local machine, i want to run this local script on multiple remote machines (Linux and Windows servers) and redirect the output to local machine.

For Example:

have to run the below local scripts to remote machines and redirect the output to local

Note: The python may not be available on some of the servers in that case will it work or not.

import psutil
total_mem = psutil.virtual_memory().total
used_mem = psutil.virtual_memory().used
used_percent = psutil.virtual_memory().percent

print("Total Mem:{}" .format(int(total_mem / 1000 ** 3)))
print("Used Mem:{}" .format(int(used_mem / 1000 ** 3)))
You need to set up a server socket on your local machine, and a socket on the remote, and connect them.

See: https://docs.python.org/2/howto/sockets.html and https://realpython.com/python-sockets/