fixed bind-input/output
This commit is contained in:
parent
66623cd675
commit
432c7d8364
13
bind-input
13
bind-input
|
@ -37,8 +37,8 @@ touch $BUFFER;
|
|||
(
|
||||
|
||||
echo " > binding port $IN_PT to $BUFFER";
|
||||
trap "kill -9 $NC_PID 2>/dev/null; exit 1;" HUP INT KILL TERM;
|
||||
|
||||
trap "kill -9 $NC_PID 2>/dev/null" INT KILL;
|
||||
infail=0;
|
||||
|
||||
# (1) kill script after 10 failures
|
||||
|
@ -61,7 +61,7 @@ touch $BUFFER;
|
|||
|
||||
# (5) Bind input
|
||||
infail="0";
|
||||
( nc -lp $IN_PT >> $BUFFER 2>/dev/null )&
|
||||
nc -lp $IN_PT >> $BUFFER 2>/dev/null&
|
||||
NC_PID=$!;
|
||||
wait $NC_PID;
|
||||
|
||||
|
@ -74,10 +74,13 @@ LOOP_PID=$!;
|
|||
# (2) Remove buffer + kill loop #
|
||||
on_exit(){
|
||||
echo " < closing binding port $IN_PT to $BUFFER";
|
||||
rm $BUFFER 2>/dev/null;
|
||||
kill -9 $LOOP_PID 2>/dev/null;
|
||||
rm $BUFFER 2>/dev/null && echo " < $BUFFER deleted";
|
||||
|
||||
kill -INT $LOOP_PID 2>/dev/null;
|
||||
|
||||
exit 1;
|
||||
}
|
||||
trap "on_exit;" INT KILL;
|
||||
trap "on_exit;" HUP INT KILL TERM;
|
||||
|
||||
wait $LOOP_PID;
|
||||
|
||||
|
|
16
bind-output
16
bind-output
|
@ -37,8 +37,8 @@ touch $BUFFER;
|
|||
#--------------------------------------------------------#
|
||||
(
|
||||
echo " > binding $BUFFER to $OUT_IP:$OUT_PT";
|
||||
trap "kill -9 $NC_PID 2>/dev/null; exit 1;" HUP INT KILL TERM;
|
||||
|
||||
trap "kill -9 %1 2>/dev/null" INT KILL;
|
||||
outfail=0;
|
||||
|
||||
# (1) kill script after 10 failures
|
||||
|
@ -61,8 +61,9 @@ touch $BUFFER;
|
|||
|
||||
# (5) Bind output
|
||||
outfail="0";
|
||||
( tail -f $BUFFER | nc $OUT_IP $OUT_PT 2> /dev/null )&
|
||||
wait $!;
|
||||
tail -f $BUFFER | nc $OUT_IP $OUT_PT 2> /dev/null &
|
||||
NC_PID=$!;
|
||||
wait $NC_PID;
|
||||
|
||||
done;
|
||||
|
||||
|
@ -73,10 +74,13 @@ LOOP_PID=$!;
|
|||
# (2) Remove buffer + kill loop #
|
||||
on_exit(){
|
||||
echo " < closing binding from $BUFFER to $OUT_IP:$OUT_PT";
|
||||
rm $BUFFER 2>/dev/null;
|
||||
kill -9 $LOOP_PID 2>/dev/null;
|
||||
rm $BUFFER 2>/dev/null && echo " < $BUFFER deleted";
|
||||
|
||||
kill -INT $LOOP_PID 2>/dev/null;
|
||||
|
||||
exit 1;
|
||||
}
|
||||
trap "on_exit;" INT KILL;
|
||||
trap "on_exit;" HUP INT KILL TERM;
|
||||
|
||||
wait $LOOP_PID;
|
||||
|
||||
|
|
Loading…
Reference in New Issue