Find the answer to your Linux question:
Results 1 to 7 of 7
Hello! Is it possible to start a process, and then switch its stdin between different inputs? What I want to do: cat somefile | someprog but: I don't want someprog ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2006
    Posts
    10

    BASH & pipe reattachment


    Hello!

    Is it possible to start a process, and then switch its stdin between different inputs?

    What I want to do:

    cat somefile | someprog

    but: I don't want someprog to exit because cat has finished and closed the pipe, instead I want to reattach the stdin to someprog to, for example, the console so that the user may enter further data.

    Is that possible with bash? If yes, how?

    Thx in advance!

  2. #2
    Linux User fernape's Avatar
    Join Date
    Dec 2005
    Location
    Holland
    Posts
    301
    It is possible to split the output of a command in two ways (with tee command) but I'm not sure about a command can get sequentially the pipe data and then the keyboard data.

    Best regards

  3. #3
    Just Joined!
    Join Date
    Apr 2006
    Posts
    10
    Forget about the sequential thing. How about having two inputs concurrently?

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Apr 2006
    Posts
    6
    (command1; command2) | command3

    The output of command1 and command2 redirected to command3. The command1 is executed first, followed by command2.

  6. #5
    Just Joined!
    Join Date
    Apr 2006
    Posts
    10
    How do I use that to start a shell interpreter like bash, pipe some first commands to it, and then give control to the user? It is not necessary that the user has no control at the beginning. I just want to "paste" some text into the bash interpreter without using the mouse and without bash exiting afterwards.

  7. #6
    Just Joined!
    Join Date
    Apr 2006
    Posts
    6
    (cat somefile; /bin/bash ) | someprog
    Use Ctrl+D to stop the bash.

  8. #7
    Just Joined!
    Join Date
    Apr 2006
    Posts
    10
    No, I meant that bash should be "someprog"...

    Is THAT possible?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •