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