Remotely Send Variable and Run Python Script

So here is the situation..

I have a local computer A and remote computer B.

Computer A has script Computer B has script

Script a has variables x and y. Let's say x = 5, and y = 10.

I am running on Computer A, and the output is x = 5, y = 10. I want to ssh or pass these values or variables to and run on Computer B at the same time.

Is it possible?If yes, can you anyone please help me with this. Thank you!!

1 answer

  • answered 2018-11-12 16:48 Filip Młynarski

    You could run remotely on Computer B via ssh with x and y as program arguments like this:

    os.system('sshpass -p \'Bpassword\' ssh root@MachineB \'python3 {} {}\''.format(x, y))