Im not sure if there is any way of doing this...
So, i run several EPICS programs in my machine. EPICS programs usually open interpreters that can be used as a CLI for the program. To make every terminal accessible, even for background processes, i sometimes use procServ to create a telnet server in such a way that you can remotely telnet into the server and gain access to the EPICS terminal. It should work similarly with python interpreters, for example.
Is there a way that, having started a process and forgotten to initialize it with procServ, i can gain access to the interpreter terminal?
I ask this because i have several processes that i sometimes need to access and, being processes started by other users in remote machines, sometimes the only way to gain access to the terminal is to kill the process and restart it in a terminal that i have access.
Expected behavior would be something like:
In terminal 1:
python3
x = 2
In terminal 2:
ps -aux | grep python3
my_user <PID> 4.0 0.1 21272 11104 ? S+ 11:32 0:00 python3
Some_magic_command <PID>
>>>#Im now in a python interpreter
>>>print(x)
2
ps -elf | grep python3
? Hopefully you will have the 13th column having things likepts/12
in it. With this you will be able to send input to the python3, but will not be able to directly get the output. However there are workarounds. – icarus Feb 02 '23 at 16:360 S my_user 21811 21768 0 80 0 - 5318 do_sel 14:05 pts/4 00:00:00 python3
and by doingsudo su -l
thenecho "x=2" > /dev/pts/4
"x=2" was printed on the python terminal, but it is not used by the interpreter: it is only printed but typing "x" and enter in the terminal gives me messages saying that x is not defined. – Marco Montevechi Filho Feb 02 '23 at 17:09cat /dev/pts/4
gives me some scrambled version of the things typed in the python terminal, but not all. It seems im missing something. – Marco Montevechi Filho Feb 02 '23 at 17:10cat /dev/pts/4
gives you the scrambled output because there are 2 things reading the output of the python3, the original terminal program and the cat. I will write a filler answer unless someone beats me to it. – icarus Feb 02 '23 at 17:18