How to write to stdin of another process? - Unix

This is a discussion on How to write to stdin of another process? - Unix ; Hello if I have the PID of another already running process is it possible to write to its stdin? I guess it is possible so the question is HOW? I managed to send data to the stdin file of the ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to write to stdin of another process?

  1. How to write to stdin of another process?

    Hello
    if I have the PID of another already running process is it possible to write
    to its stdin? I guess it is possible so the question is HOW?
    I managed to send data to the stdin file of the process and it was displayed
    in the console where the process was running but it wasn't actually read by
    the process
    Thank you in advance
    --
    There are 10 types of people - those who understand binary and those that
    don't

  2. Re: How to write to stdin of another process?

    Paul wrote:
    > if I have the PID of another already running process is it possible to write
    > to its stdin? I guess it is possible so the question is HOW?


    To an arbitrary process, which was not started in any special way?
    No. There are ways to do it if you can control how the process starts,
    though. For example, you could create a FIFO and make the process take
    input from it, then write data to the FIFO. Using "screen" might also
    do what you want, depending on what your requirements are.


    > I managed to send data to the stdin file of the process and it was displayed
    > in the console where the process was running but it wasn't actually read by
    > the process


    Correction: you managed to send data to the terminal which was
    stdin and stdout of the process. That's not the same thing as sending
    it to the stdin of the process, as you discovered.

    Xposted and f'ups set, since this is not really an admin-type question.

    JDW


  3. Re: How to write to stdin of another process?

    Paul wrote:
    >
    > if I have the PID of another already running process is it possible

    to write
    > to its stdin? I guess it is possible so the question is HOW?


    I'm not sure it's possible using normal means, but
    on Solaris the place I would start is the
    pseudo-filesystem /dev/fd. It has the file
    descriptors or open files by process. Next place to
    look is the pseudo-filesystem /proc. Different
    versions give different amounts of stuff, so the
    Linux one has a lot more than the Solaris one.


  4. Re: How to write to stdin of another process?

    In article <1111687114.841878.45460@z14g2000cwz.googlegroups.c om>,
    "Doug Freyburger" wrote:

    > Paul wrote:
    > >
    > > if I have the PID of another already running process is it possible

    > to write
    > > to its stdin? I guess it is possible so the question is HOW?

    >
    > I'm not sure it's possible using normal means, but
    > on Solaris the place I would start is the
    > pseudo-filesystem /dev/fd. It has the file
    > descriptors or open files by process. Next place to
    > look is the pseudo-filesystem /proc. Different
    > versions give different amounts of stuff, so the
    > Linux one has a lot more than the Solaris one.


    That won't solve the problem. If you write to one of these, you'll send
    your output to the same device that the process would when writing to
    that descriptor. It still won't let you feed *input* to the process.

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***

+ Reply to Thread