CFX_TELNET - Cold Fusion custom tag - by Dosolutions Inc.

OVERVIEW

This tag allows web developers who run Cold Fusion on their webserver to connect to remote telnet servers via a browser interface. Once connected, a session ID is established which allows information to be sent and responses returned from the given telnet server. Information is passed back and forth in plain text, and can be parsed for any string the developer desires. Sessions remain open either until explicitly closed by a call to the tag, or automatically when the Cold Fusion service is stopped.

The tag supports multiple concurrent sessions, file logging, variable wait times between sending a string and looking for a response, and session management. Variable wait times can be used to tune the tag's performance with slow-to-respond servers. Since session reporting and management present a security risk, these functions are switched on and off in the cfx_telnet.ini file. File logging allows system administrators to monitor the tag's activity, and has a verbosity INI file setting to control what the tag reports.

OS and Support

This tag has been tested on Windows NT4 and Windows 2000 Servers with CF 4.5, CF 5.x and CFMX 6x - This tag HAS NOT been fully tested and (shown to work reliably) in Windows Server 2003 environments.

There are two basic versions available; \
1. Basic tag DLL with examples.
2. Deluxe tag DLL and service. The deluxe tag is somewhat more capable with "full duplex" communications, however it requires that an additional service be running on the server.

Support is limited. Please download the 30 day trial and check it out before making a purchase request.

 

TAG INSTALLATION

All the necessary files are included in the release package. Unzip the archive into a Temporary directory, and run SETUP.EXE. Files will be installed into the directories shown below. Setup automatically updates the registry in order to register the tag with Cold Fusion.
File Set
File(s)
-------
Directory
---------
cfx_telnet.dll [Cold Fusion Dir]\bin\
cfx_telnet.ini [WINNT Dir]\
*.cfm [Webserver Doc Root]\telnet\

TAG USAGE

(examples below)
<CFX_TELNET
   NAME="text"
   ACTION="text"
   HOST="text"
   PORT="integer"
   SESSIONID="text"
   COMMAND="text"
   PAUSE="integer"
   TIMEOUT="integer"
   NOCRLF="text"
   NOECHO="text"
>
ATTRIBUTES:
Title Description
NAME Required. Any string that's unique for a given template.
ACTION Required. Can be one of the following strings: "OPEN", "SEND", "CLOSE", "GETSESSIONS", or "CLOSEALL". If the action is "OPEN", then the HOST and PORT attributes are required as well. On return from an OPEN action, variable parameter, "#telnet_sessionID#", will have a value that can be used to reference further commands sent to a given telnet connection. If the action is "SEND" or "CLOSE", then the SESSIONID attribute is required.

The "GETSESSIONS" command returns a set of records containing all currently open session IDs in the #SESSIONID# return, and associated host address in the #HOST# return.

The "CLOSEALL" command attempts to close all currently open sessions, and returns the #ERRLEVEL# and #ERRMSG# that results.

The "GETSESSIONS" and "CLOSEALL" action commands are enabled by entries in the CFX_TELNET.INI file, which must live in Windows root directory. Since enabling these tags presents a security risk, they default to being *disabled*.

HOST Required for the OPEN action. Can be either a domain name, or an IP address.
PORT Optional for the OPEN action. A port number to connect to on the remote machine. Defaults to port number 23.
SESSIONID Required for SEND and CLOSE actions. A session identifier returned from a previous OPEN action.
COMMAND Required for SEND action. A command, as text, to send to the telnet host.
PAUSE Optional. A number, in deciseconds, indicating how long the tag ought to wait between sending a given command, and looking for a response. This attribute controls latency on the client side of the connection.
TIMEOUT Optional. A number, in seconds which limits the time the tag will wait for the server before timing out. Defaults to "10". This attribute controls latency on server side of the connection. Relatively busy servers ought to be given higher timeout values.
NOCRLF Optional. Specifies whether or not to append a newline to the end of a given command. Defaults to "off". Set equal to "1", "on" or "yes" to stop the tag from automatically appending a newline.
NOECHO Optional. Turns on or off local command echoing. Defaults to "off". Enable to turn echoing off.

RETURNS:
Command Returned Variables
OPEN #ERRMSG#
#ERRLEVEL#
#SESSIONID#
#RETURN_DATA#
SEND #ERRMSG#
#ERRLEVEL#
#RETURN_DATA#
CLOSE #ERRMSG#
#ERRLEVEL#
#SESSIONID#
GETSESSIONS #ERRMSG#
#ERRLEVEL#
#SESSIONID#
#HOST#
CLOSEALL #ERRMSG#
#ERRLEVEL#


Examples

Opening a Session

<cfx_telnet host="shell.sover.net"
            action="open"
            name="host_open"
>
<cfoutput>
OPEN action returned:<br>
Error Level == #host_open.errlevel#<br>
Error Message == #host_open.errmsg#<br>
SessionID == #host_open.sessionid#<br>
Server Response:
<pre>
#host_open.return_data#
</pre>
</cfoutput>

Sending a Command to a Session

<cfx_telnet sessionid="#host_open.sessionid#"
            action="send"
            name="send_cmd"
            command="username"
            pause="2000"
            nocrlf="0"
>
<cfoutput>
SEND action returned:<br>
Error Level == #send_cmd.errlevel#<br>
Error Message == #send_cmd.errmsg#<br>
<pre>
#send_cmd.return_data#
</pre>
</cfoutput>

Closing a Session

<cfx_telnet sessionid="#ID#"
            action="close"
            name="host_close"
>

<cfoutput>
Error Level == #host_close.errlevel#<br>
Error Message == #host_close.errmsg#<br>
</cfoutput>
</pre>

Retrieving All Open Sessions

<cfx_telnet action="GETSESSIONS"
            name="tel_sessions"
>
<cfoutput query="tel_sessions">
<pre>
Error Level: #errlevel#
Error Message: #errmsg#
SessionID: #sessionid#
Host: #host#
</pre>
</cfoutput>

Closing All Open Sessions

<cfx_telnet action="CLOSEALL"
            name="closeall"
>
<cfoutput>
<pre>
Error Level: #closeall.errlevel#
Error Message: #closeall.errmsg#
SessionID: #closeall.sessionid#
Host: #closeall.host#
</pre>
</cfoutput>

Back to top

Copyright 2004 Dosolutions. All Rights Reserved.
Cold Fusion is a registered trademark of Allair, no... Macromedia no... Adobe