4

I have a simple python script:

import time
counter = 0
while True:
    print counter
    counter = counter + 1
    time.sleep(10)

Let's say this is running on my linuxbox inside LAN and is printing the output to the terminal that linuxbox. If I am to ssh into that server, I want to see the status of counter variable. In other words, I want to change the I/O of the program from default terminal to ssh terminal.

So far I've tried to put the process in background by using fg without any luck.

Here's a snapshot (from ssh terminal)

jarwin@ubuntu:~$ ps -a
  PID TTY          TIME CMD
30412 pts/1    00:00:02 python
30591 pts/10   00:00:00 ps
jarwin@ubuntu:~$ fg %30412
-bash: fg: %30412: no such job
jarwin@ubuntu:~$ top | grep gnome
27337 azazel    20   0  625656  35804  24676 S  0.3  1.4   1:03.01 gnome-terminal-        
jarwin@ubuntu:~$ fg %27337
-bash: fg: %27337: no such job

Is it possible to do that? And in case python does not allow that, is it possible to change to ssh terminal for a ping command?

PS: I am using JuiceSSH on Android as my ssh-client

Pang
  • 373
Jarwin
  • 325

1 Answers1

3

You can try your luck with tmux or screen, which allows you to to connect to existing terminal sessions.

The other workaround I would consider is to use some temporary file, where you would write the output (if the output is kind of log) and then follow the new lines in the file using tail -f.

David Foerster
  • 36,264
  • 56
  • 94
  • 147
Jakuje
  • 6,605
  • 7
  • 30
  • 37