Re: Script for telnet server to communicate with J2EE application
- From: Martin Gregorie <martin@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 07 Sep 2006 20:02:23 +0100
Lalit wrote:
As you were asking about using telnet client classes to allow your Java application to talk to a telnet server, I was assuming you'd want to use something like the following to login, send one barcode to the telnet server and logout again:#!/bin/sh
echo "$1" >>barcode_file
If the script is called store_barcode, the command
"store_barcode xxxxyyyy"
where xxxxyyyy is the bar code which will be appended to barcode_file.
Of course, you'll need to add error traps, etc.
Martin,
That's really an idea i was looking for.
Is there any way that this script automatically get invoked as the
Telnet Client login to Server? So that client need not to specify
store_barcode everytime. Just sending xxxxxyyyy, and the barcode get
appended to the file.
Telnet tnc = new Telnet();
tnc.login(hostname, username);
tnc.password(password);
tnc.sendCommand("store_barcode " + barcode);
if (tnc.responseOK())
tnc.logout();
else
/* report errors and clean up */
.... that is, assuming that there is a telnet client class with methods corresponding roughly to the actions you'd take if you were manually running a telnet session.
You can get a script to execute automatically with one of the following:
- if you have root access to the server you could use a captive login
in place of the shell
- you can change the bash .profile file in the user to do much the same.
HOWEVER, once you've done that you can't login to that user normally, because doing so will always run your script and then logout. That means you'll need a second (normal) login user with full access rights over the first user so you can get in for maintenance, e.g. to install a modified version of your script, run unit tests or to clean up after a failure. But why bother? The method I outlined is easy to do and still allows normal logins to the user via a normal telnet session.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
.
- Follow-Ups:
- References:
- Prev by Date: Swing/AWT on a custom display? (catch repaint() calls)
- Next by Date: Re: Retrieve the key from a map (2)
- Previous by thread: Re: Script for telnet server to communicate with J2EE application
- Next by thread: Re: Script for telnet server to communicate with J2EE application
- Index(es):
Relevant Pages
|
|