Re: Script for telnet server to communicate with J2EE application



Lalit wrote:
#!/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.

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:

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



Relevant Pages

  • Re: Need help sending a password to ftp
    ... > then bring up ftp on that system to transfer some files over there. ... > can get the telnet session open. ... The script fails with: ... > 530 Login incorrect. ...
    (comp.lang.perl.misc)
  • Expect, telnet, frozen console.
    ... telnet into remote host, provide username/password, surrender control to ... This script will eventually be tied into /etc/inittab so that it ... app called 'loe' which presents a login screen in 80x24 ASCII a la ...
    (comp.lang.tcl)
  • Need help sending a password to ftp
    ... I need to create a perl/expect script that will telnet into a system ... then bring up ftp on that system to transfer some files over there. ... 530 Login incorrect. ...
    (comp.lang.perl.misc)
  • Problems getting ftp to take my password
    ... I need to create a perl/expect script that will telnet into a system ... then bring up ftp on that system to transfer some files over there. ... 530 Login incorrect. ...
    (comp.lang.perl.modules)
  • Net::Telnet
    ... If I run this to a solaris telnet server, I get the greeting message and a prompt. ... If I run this to a WinXP telnet server, ... I tried chaning the login line to tn.login, followed by a tn.puts, but it still did not get past the tn.loginline. ...
    (comp.lang.ruby)