Tag Info

New answers tagged

-1

One possibility (if that doesn't break other things) is to insert a call to tee. The command tee duplicates the data, so you can have one copy going to your application and one going to the debug output. Instead of invoking your_application, arrange to invoke tee input.log | your_application. If the input to your application was a file, this isn't an ...


0

On linux you can address an application's file-descriptors as named files in /dev/fd/[0-9]. And what you definitely can do with a named file and an input stream is tee the input into that file and to stdout. And so what I usually do when I find myself in your situation (as I often do) is tee input off to both my reading application and to /dev/fd/2 - stderr. ...


2

strace ? Example below. Start a cat process which is reading stdin and writing to /tmp/foofile. Find the pid, strace it. And in the original cat window, enter some text, hey presto. # cat >/tmp/foofile # ps -ef|grep cat steve 2134 1801 0 22:25 pts/2 00:00:00 cat # strace -fp 2134 Process 2134 attached read(0, "test\n", 65536) ...


2

This is really easy, actually, First, you need to set aside your stdin in some remembered descriptor: exec 9<&0 There. You've made a copy. Now, let's pipe our commands at our shell. echo 'echo foo; read <&9; echo bar' | bash ...well, that was easy. Of course, we're not really done yet. We should clean up. exec 9<&- Ok, now we're ...


1

ikrabbe's answer correctly identifies why your command line doesn't work the way you expect it to.  The conventional way to invoke a new shell for one command line is: $ sh -c 'echo foo; read; echo bar' Of course you can use bash if you need to, but 98% of what you might want to do in a one-line shell script can be done in the plain old shell.  (Pay no ...


3

The bash builtin read reads from stdin (fd0), but it cannot open stdin as the bash command itself already consumes stdin. You can eval what you pipe eval 'echo foo;read;echo bar' Was: I can't think of another way to pipe a shell script that itself needs to read from stdin. When you pipe into a shell, that shell is not interactive. I never got it how to ...



Top 50 recent answers are included