I created it because I needed it to create a stub, so I wanted a command that behaves like a local command, but actually prints the command results remotely.
OSX El Capitan
Save the source with a file name of ls. Grant execute permission with chmod + x ls. All you have to do is ls.
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import sys
import os
from subprocess import call
argvs = sys.argv
param_hostname = '1.2.3.4'
param_username = 'docker'
param_port = '60000'
param_command = os.path.basename(argvs[0])
param_command_param = ' '.join(argvs[1:])
cmd = '/usr/bin/ssh -l %s -p %s %s %s %s' % (
param_username, str(param_port), param_hostname, param_command, param_command_param)
call( cmd.strip().split(' ') )
butada-mac:remote_exec_like_a_local butada$ ./ls -l
nothing special
Recommended Posts