|
|
||||||
|
#1
|
|
|
|
|
Hi,
I try to make a wrapper around an existing program, which would behave exactly the same as the original one. But my following attempt was failed. Would you pleaes let me know what is the correct way? Thanks, Peng $cat ./my_tee.sh #!/bin/bash read echo $REPLY | tee $* $ cat abc a b c $ cat abc | ./my_tee.sh efg a |
|
|
|
#2
|
|
|
|
|
On Thursday 3 July 2008 20:24, PengYu.UT wrote:
[..] > > read > > echo $REPLY | tee $* > $ cat abc > a > b > c > $ cat abc | ./my_tee.sh efg > a What about cat abc | efg or, better efg < abc or, better yet, explain what you're trying to do? |
|
#3
|
|
|
|
|
On Jul 3, 1:31 pm, pk <p...@pk.invalid> wrote:
> On Thursday 3 July 2008 20:24, PengYu...@gmail.com wrote: >> >> >> > What about > > cat abc | efg > > or, better > > efg < abc > > or, better yet, explain what you're trying to do? I'm trying to mimic an existing command. Of course, in practice, the new command is different from the old one, otherwise, this is no point. As a simplification, in my example, the new command (my_tee.sh) shall do the same thing as the old command (tee). The point is that I want the new one accept exactly the same set of command line arguments as well as the stdin as the old one. Thanks, Peng |
|
#4
|
|
|
|
|
On Jul 3, 2:24 pm, "PengYu...@gmail.com" <PengYu> wrote:
[..] > > read > > echo $REPLY | tee $* > $ cat abc > a > b > c > $ cat abc | ./my_tee.sh efg > a most shells support "here-docs" so something like: ./my_tee.sh efg <<-ENDIT a b c ENDIT ought to work, or look at "expect". |
|
#5
|
|
|
|
|
On 2008-07-03, PengYu.UT wrote:
> Hi, > > I try to make a wrapper around an existing program, which would behave > exactly the same as the original one. But my following attempt was > failed. Would you pleaes let me know what is the correct way? That depends on what you want to do. > $cat ./my_tee.sh > #!/bin/bash > > read > > echo $REPLY | tee $* > $ cat abc > a > b > c > $ cat abc | ./my_tee.sh efg > a How about: tee "$@" | do_whatever Replace 'do_whatever' with whatever you want to do to the input. |
|
#6
|
|
|
|
|
On 2008-07-03, PengYu.UT <PengYu.UT> wrote:
[..] > > read > > echo $REPLY | tee $* > $ cat abc > a > b > c > $ cat abc | ./my_tee.sh efg > a IFS= while read; do echo "$REPLY" done |tee "$@" or IFS= while read; do echo "$REPLY" | tee -a "$@" done |
|
|
| Similar Threads | |
| Best way to input from stdin? I'm writing a program that supports input from stdin. To be able to do that I tend to rely on a simple loop that tests the return of fgets(), such as the following... |
|
| Any way to take a word as input from stdin ? I searched the c.l.c archives provided by Google as Google Groups with "word input" as the key words and did not come up with anything good. C++ has std::string for taking... |
|
| Input using stdin How can I give input to a program using STDIN Suppose I want the program to take the value x=10 On some other site i found it as STDIN.read,but its not working. |
|
| getting input from stdin Hi Im new to unix scripting and now Im trying to get user input from stdin and this is what I did echo "enter your name: " read name and it will run with the pointer to... |
|
| Checking available input on stdin I know this has probably come up frequently, but couldn't find a satisfactory reference... I have some code which needs to read from stdin but must not block waiting for... |
|
|
All times are GMT. The time now is 04:32 PM. | Privacy Policy
|