linux - Running Local Script On SSH Server -
i'm using linux
log server using ssh
. once i'm logged in, execute local python
script uses netcat
run program on remote machine (it therefore required logged in access it).
locally can type ./script.py
on bash
run script if while being connected remote server doesn't work. due fact terminal in directory on remote machine , no longer in local one.
so how execute local script against remote machine while being logged in without copying on first?
you can using pipes:
sample program test: (py.py)
import socket print socket.gethostname()
running remotely:
ssh remoteserver "python" < py.py
the output was:
remoteserver name
if user's path not contains python, must use full path
ssh remoteserver "/usr/bin/python" < py.py
in environment.
Comments
Post a Comment