I have to run python code on remote python process.
Normally, what I would do is:
ssh admin@localhost -p 61234
which opens a interactive python console and I can execute python code directly.
>>> print('3')
3
>>>
But I want to automate this and pass python code as parameter to ssh.
I tried following options:
ssh admin@localhost -v -p 61234 python logs.py
ssh admin@localhost -v -p 61234 nohup python logs.py
ssh admin@localhost -p 61234 < logs.py
cat logs.py | ssh admin@localhost -p 61234 python -
But all options give following error:
shell request failed on channel 0
logs.py:
#!/usr/bin/env python
# tried with and without first line.
print('3')
netstat -anp | grep 61234
tcp 0 0 127.0.0.1:61234 0.0.0.0:* LISTEN 6/python2.7
Is there a way to do this?