Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Streaming output of a remotely executed program via ssh

Tags:

python

ssh

Is it possible to stream the output of a program that is being executed via ssh?

Example program (test.py on remote):

import time
while True:
    print time.time()
    time.sleep(1)

Command (local):

ssh name@remote 'python test.py'

Since the program never terminates, the output is not streamed; is this possible in some way?

like image 416
reinzor Avatar asked Mar 17 '23 20:03

reinzor


1 Answers

Apparently, adding the -t option to the ssh command works. It flushes the stdout:

ssh -t name@remote 'python test.py'
like image 83
reinzor Avatar answered Apr 01 '23 14:04

reinzor