The Moose and Squirrel Files

September 26, 2011

A bash Telnet Client for Checkpoint Secureplatform

Filed under: checkpoint, linux — networknerd @ 9:27 pm

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.

  1. The exec statement to connect file handle 3 to our socket.
  2. Reading the input of the file handle and using cat to send it to the screen.
  3. 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<&-
About these ads

2 Comments »

  1. 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


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: