0

I wonder if I can use stdout from python code as an input for another daemon process such as gnome-calculator for instance and if so how could I achieve that.

The goal is to automate the interaction with an app (not with gnome-calculator) later on (pen-testing would be one application).

I know how I would do that with two processes that are both launched from the terminal, for instance:

python ps1.py | python ps2.py

I've also read that you can interact with processes using proc/$pid directory, but I don't understand how would one do that either.

  • Have you tried doing it? What problems have you run into with your solution? – gstukelj Jul 16 '21 at 11:51
  • I don't quite understand how would I redirect python output from terminal to a already running daemon process. I know how it can be done with a pipe and two processes launched from the terminal. – The August Georgian Jul 16 '21 at 11:54
  • Does this answer your question? [Is it possible to pass input to a running service or daemon?](https://stackoverflow.com/questions/40732425/is-it-possible-to-pass-input-to-a-running-service-or-daemon) – gstukelj Jul 16 '21 at 12:03
  • Perhaps what's confusing you is the `$PID` part -- you should replace it with the actual `pid` (process id) of the deamon that you want to write to. Of course, the default `fd` (file descriptor) corresponding to the `stdout`, i.e., 0, might not be used by the deamon in question, but then you should just try with other `fd`s opened by that process. – gstukelj Jul 16 '21 at 12:11
  • No, that's not what is confusing me. So I opened up gnome-calculator and then I ran ```python3 ~/Desktop/ps1.py > /proc/7527/df/0``` 7527 being gnome-calculator PID, ps1.py just prints 12, shouldn't I be seeing the output on the running gnome-calculator? – The August Georgian Jul 16 '21 at 12:16
  • Or say ```echo 12 > /proc/7527/df/0``` – The August Georgian Jul 16 '21 at 12:16
  • I don't know, is this how gnome-calculator works? (Most likely a typo, but it should be `/proc/7527/fd/0`.) – gstukelj Jul 16 '21 at 12:25
  • To be honest, I don't know that either... I'll try it on some other programs. You're right it is a typo and thanks tons, I've definitely learnt something new!! – The August Georgian Jul 16 '21 at 12:31

0 Answers0