nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #! /bin/bash
2 # source: cat2.sh
3 # Copyright Gerhard Rieger 2009
4 # Published under the GNU General Public License V.2, see file COPYING
5  
6 # This is an example script that shows how to write a script for use with socat
7 # intermediate addresses. it shows a simple case consisting of two
8 # unidirectional programs.
9 # note how the n>&- and n<&- controls are used to close FDs on sub processes
10 # to make half close possible.
11  
12 # uncomment this if you want to analyse which file descriptors are open
13 #filan -s -o+2; sleep 1; echo
14  
15 # these are the "right side" file descriptors provided by socat; 0 and 1 are
16 # the "left side" FDs
17 RINFD=3
18 ROUTFD=4
19  
20 if true; then
21  
22 # this is a typical example.
23 #these work fine
24 socat -u - - <&3 3<&- 4>&- & # right (3) to left (1)
25 socat -u - - <&0 >&4 4>&- 3<&- & # left (0) to right (4)
26 #strace -o /tmp/cat.strace -v -tt -f -F -x -s 1024 cat <&3 3<&- 4>&- & # right (3) to left (1)
27 #cat <&0 1>&- >&4 4>&- 3<&- & # left (0) to right (4)
28 exec 1>&- 4>&-
29 exec 0<&- 3<&-
30  
31 elif false; then
32  
33 # works except close in reverse direction
34 cat <&3 3<&- 4>&- & # right (3) to left (1)
35 exec cat <&0 1>&- >&4 4>&- 3<&- # left (0) to right (4)
36  
37 elif true; then
38  
39 # works - forw, rev
40 #socat $SOCAT_OPTS -u fd:$RINFD - </dev/null 4>&- & # right to left
41 #socat $SOCAT_OPTS -u - fd:$ROUTFD >/dev/null 3<&- & # left to right
42 exec 1>&- 4>&-
43 exec 0<&- 3<&-
44  
45 elif false; then
46  
47 # works - forw, rev
48 socat -u - - <&3 3<&- 4>&- & # right (3) to left (1)
49 exec socat -u - - <&0 1>&- >&4 4>&- 3<&- # left (0) to right (4)
50  
51 else
52  
53 # works except close in reverse
54 #filan -s -o+2 <&3 3<&- 4>&- & # right (3) to left (1)
55 cat <&3 3<&- 4>&- & # right (3) to left (1)
56 #socat -d -d -d -d -u - - <&3 3<&- 4>&- & # right (3) to left (1)
57  
58 #sleep 1; echo >&2; filan -s -o+2 <&0 >&4 4>&- 3<&- & # left (0) to right (4)
59 #cat <&0 >&4 4>&- 3<&- & # left (0) to right (4)
60 socat -u - - <&0 >&4 4>&- 3<&- & # left (0) to right (4)
61  
62 exec 1>&- 4>&-
63 exec 0<&- 3<&-
64 #sleep 1; echo >&2; filan -s -o+2
65  
66 fi
67  
68 wait