UPDATED: As Dreezman pointed out in the comments there is a telnet client on the distribution media. I’ll leave this post up though so I can refer back to it for hints on Linux IO redirection.
Checkpoints secureplatform doesn’t come with a telnet client pre-installed. While this generally isn’t a major problem there are times where life would be simpler if you had telnet to connect to an adjacent router, or even to check connectivity with an SMTP relay.
The bash shell script below is simple yet still capable enough to meet these occasional demands. Without all the niceties the script amounts to just three lines.
- The exec statement to connect file handle 3 to our socket.
- Reading the input of the file handle and using cat to send it to the screen.
- Reading STDIN (keyboard) and writing it to our file handle.
A great example of how powerful linux IO redirection can be.
#! /bin/bash
#
# Workaround for lack of telnet client on Secureplatform
# Uses Bash IO redirection to tcp sockets
#
usage(){
echo "USAGE: $0 host port" >&2
}
#Check we have the right number of args on the command line
if [ -z "$1" -o -z "$2" ]; then
usage
#Check if the script is sourced.
#We use return if it is to avoid exiting the parent shell
if [ "$0" == "bash" ]; then
return -1
else
exit -1
fi
fi
#Redirect input and output from the socket to filehandle
exec 3<>/dev/tcp/$1/$2
#Output from the file handle goes to the screen,we run this process in background
cat <&3 &
#Input from the keyboard goes to our file handle. CTRL-C to exit.
cat >&3
#Close Output then input
exec 3>&-
exec 3<&-
Telnet is in the splat distribution. You can rpm -i it.
Comment by dreezman — January 19, 2012 @ 10:37 pm
Your absolutely right. It was there on the distribution media and the same rpm from the R75 DVD installed and ran nicely on R65, R70 and R75.20.
Thanks for letting me know.
Comment by networknerd — February 4, 2012 @ 7:36 pm