stdout - bash - redirect specific output from 2nd script back to stdin of 1st program? -


i have little program, let's call "program" simplicity has "normal" behaviour. takes information stdin (normally typed in user in keyboard) , prints out via stdout/stderr. want automate process , therefore redirect stdout/stderr "my little bash script" (which program in c/c++). takes it's standard input , filters it. means leaving out unimportant information.. , adding further information generated bash script itself. output shown on sreen (printed out echo command).

this working far:

program --verbose 2>&1 | ./mylittlebashscript.sh 

scheme:

 stdin     +---------------+              +---------------+  --------->|               |--stdout--+-->|            |-->screen            |    program    |          |   |    little     |            |               |--stderr--|   |  bash script  |            +---------------+              +---------------+ 

now want go 1 step further: program expects input user want give automatically little bash script. example prompts user enter path specific file. path known little bash script , bash script knows when program waiting input (as last line being printed out contains "greped"). how can pipe some information out of bash script? not want pipe stdout because several information needs displayed on screen , program not output.

new scheme:

 (stdin?)  +---------------+              +---------------+   (stdout?)  -------+->|               |--stdout--+-->|            |-->screen         |  |    program    |          |   |    little     |         |  |               |--stderr--+   |  bash script  |----+(maybe         |  +---------------+              +---------------+    | stderr?)         |                                                      |         +------------------------------------------------------+ 

at moment not familiar linux yet. guess there possibility working cat, fifos, tee , pipes/redirections. unfortunately haven't brought life far.

i'd happy little example! thank much!

cheers matthias

ps: think thread related: how redirect stdout of 2nd process stdin of 1st process?

edit: ok, fruther explanation took test files test machine:

i replaced "program" batch file called input.sh:

#!/bin/bash echo "input.sh: give me input, waiting input 1" read x echo $x echo "input.sh: give me input, waiting input 2" read x echo $x 

and got second 1 ("mylittlebashscript.sh"), called inter.sh process:

#!/bin/bash echo "inter.sh: start" while read line ;   echo "inter.sh: line>$line"   notfound=$(echo $line | grep "waiting")   if [[ "$notfound" ]];     echo "inter.sh: input sh seems wait input! putting in fifo"     #echo "banana" > testfile     #echo "i stderr" >&2   fi  done echo "inter.sh: end" exit 

an additional expect-like software tool empty!

http://empty.sourceforge.net


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -