LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   piping input during run-time (https://www.linuxquestions.org/questions/linux-newbie-8/piping-input-during-run-time-675960/)

lin2winwin 10-13-2008 01:45 AM

piping input during run-time
 
Hi,
I have an interactive application (shell) that takes input during runtime. Now, I need to create a channel such a way that when I write to that channel, the input goes to that application. After executing that line, it should wait for next input (through that channel).

I dont know how to do that in bash using redirections, (and how to google for that).

Basically, I want something like this

### Start the application
$ appln [operator] inputchannel > outputfile &
### Send commands to the appliation that runs in background
$ echo "command1 args" > inputchannel
$ echo "command2 args" > inputchannel
....


Can anyone please help me?

Thanks.

lin2winwin 10-13-2008 02:46 AM

I figured it out. But, dont know if its the right way


Create a script "run.sh" like

Code:

rm my_pipe
mknod my_pipe p
str="tmp"
while [ $str <> "exit" ];
do
        str=`cat my_pipe`;
        echo $str;
        if [ $str == "exit" ]; then
                break;
        fi;
done

Then, run the application (in this case bash shell) as

./run.sh | bash

This script would exit at the command "exit".

I guess there should be some better way to do it...


All times are GMT -5. The time now is 09:08 AM.