Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # will use this to find out whether the command received the input
- bash-4.1$ cat iotest.sh
- #!/bin/bash
- read -t 1 in
- out="$RANDOM"
- echo "TEST INPUT $in" >&2
- echo "TEST OUTPUT $out" >&2
- echo "$out"
- # with "|" in front, input can be sent to the command, but command's output can not be read
- bash-4.1$ perl -e 'open F,"|./iotest.sh";$out=rand;$in=<F>;print F"$out\n";close F;print"PERL INPUT $in\nPERL OUTPUT $out\n"'
- TEST INPUT 0.129122755098255
- TEST OUTPUT 26687
- 26687
- PERL INPUT
- PERL OUTPUT 0.129122755098255
- # "|-" mode string is similar with above
- bash-4.1$ perl -e 'open F,"|-","./iotest.sh";$out=rand;$in=<F>;print F"$out\n";close F;print"PERL INPUT $in\nPERL OUTPUT $out\n"'
- TEST INPUT 0.261993898618133
- TEST OUTPUT 27450
- 27450
- PERL INPUT
- PERL OUTPUT 0.261993898618133
- # with "|" behind, output can be read from the command, but the command can not get input
- bash-4.1$ perl -e 'open F,"./iotest.sh|";$out=rand;$in=<F>;print F"$out\n";close F;print"PERL INPUT $in\nPERL OUTPUT $out\n"'
- TEST INPUT
- TEST OUTPUT 18103
- PERL INPUT 18103
- PERL OUTPUT 0.571054091750742
- # "-|" mode string is similar with above
- bash-4.1$ perl -e 'open F,"-|","./iotest.sh";$out=rand;$in=<F>;print F"$out\n";close F;print"PERL INPUT $in\nPERL OUTPUT $out\n"'
- TEST INPUT
- TEST OUTPUT 23718
- PERL INPUT 23718
- PERL OUTPUT 0.985680787664936
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement