Python Forum
How to run local python script to remote machine without sending - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: How to run local python script to remote machine without sending (/thread-16286.html)



How to run local python script to remote machine without sending - krishna1989 - Feb-21-2019

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)))



RE: How to run local python script to remote machine without sending - marienbad - Feb-21-2019

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/