python: execute function on remote file through ssh.



os.system('ssh USER@REMOTE_IP python3 /PATH/TO/REMOTE/ ARGUMENT')


note than the argument i'm using is 1 (as a random character, you can use whatever you like)


then on the file you "fish" the argument and use an if statement (sorry for the lack of tabs on the code below)


import sys

argument = sys.argv[1]

print('the argument is: ' + argument)

if argument == '1':
print('will execute the leads cleanup')
print('no argument')




Leave a Reply

Your email address will not be published. Required fields are marked *