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 a.py Computer B has script b.py

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

I am running a.py on Computer A, and the output is x = 5, y = 10. I want to ssh or pass these values or variables to b.py and run b.py 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 b.py remotely on Computer B via ssh with x and y as program arguments like this:

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