Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebbc590
commit d0c34c7
Showing
2 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
function usage { | ||
echo "USAGE: send-to DEST [PORT] [SUBNET]" | ||
echo " DEST: hostname of member of secondary network [green, tank, nissan]" | ||
echo " PORT: port number to send TCP stream to, default 8888 [0-65535]" | ||
echo " SUBNET: subnet of secondary network to use [1, 2]" | ||
} | ||
|
||
DEST=$1 | ||
PORT=$2 | ||
SUBNET=$3 | ||
if [ -z "$DEST" ]; then | ||
usage | ||
exit 1 | ||
fi | ||
if [ -z "$PORT" ]; then | ||
echo "WARNING: no port specified, assuming 8888" 1>&2 | ||
PORT=8888 | ||
fi | ||
if [ -z "$SUBNET" ]; then | ||
echo "WARNING: no subnet specified, assuming 1" 1>&2 | ||
SUBNET=1 | ||
fi | ||
|
||
if [ "$DEST" == "green" ]; then | ||
IP_1=172.16.1.1 | ||
IP_2=172.16.2.1 | ||
elif [ "$DEST" == "tank" ]; then | ||
IP_1=172.16.1.2 | ||
IP_2=172.16.2.2 | ||
elif [ "$DEST" == "nissan" ]; then | ||
IP_1=172.16.1.3 | ||
IP_2=172.16.2.3 | ||
else | ||
echo "ERROR: hostname $DEST not present in secondary network" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [ $SUBNET == 1 ]; then | ||
IP=$IP_1 | ||
elif [ $SUBNET == 2 ]; then | ||
IP=$IP_2 | ||
else | ||
echo "ERROR: subnet $SUBNET not present in secondary network" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
echo nc $IP $PORT | ||
nc $IP $PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters