ttylog attaches to the wrong process - release notes a bit hard to understand too

I have a lengthy python script running on a machine:

[root@server1]# ps aux | grep python
root     30640 15.6  0.6 296416 102444 pts/4   S+   11:29   2:38 python my_script.py

But I'm now working remotely on my laptop and want to view the output of that script. I would normally just tail an output file from the tee command, but that wasn't working.

So I downloaded this program called ttylog (http://search.cpan.org/~bbb/ttylog-0.83/ttylog) to view the output of the process. It seems fairly straightforward, so I've ssh'd into the same server1 and run:

[root@server1 ttylog-0.83]# ./ttylog pts/4
DEBUG: Scanning for psuedo terminal pts/4
DEBUG: Psuedo terminal [pts/4] found.
DEBUG: Found parent sshd pid [28198] for user [root]
Process 28198 attached - interrupt to quit

But that's the wrong process - so I get no output.

I need it to attach to process 30640, the python process instead. Does anyone know how to do this?


Solution 1:

ttylog does nothing special, just an strace on the ssh pid:

exec "strace","-e","read,write","-s16384","-x","-o",$write,"-p",$pid
    or die "exec: $!";

So to get some relevant results, you can simply strace the python interpreter yourself.