
Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
> #!/bin/sh
> echo "$1" >>barcode_file
[quoted text clipped - 5 lines]
> 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.
Gordon Beaton - 07 Sep 2006 14:41 GMT
> 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.
Does your device really "log in" to the server using telnet, or does
it simply use a Socket to connect to a specific port on the server?
If the former, then write a script like this:
#!/bin/sh
cat >> barcode_file
... and change the client's login shell to this script.
If the latter, configure inetd to do "cat >> barcode_file" for
connections arriving on the specified port. Or perhaps even better,
have your application listen to that port and read the values itself,
instead of using the file system as a communications mechanism.
Regardless of which method you choose, there are synchronization
issues that need to be addressed if more than one client will be
logging in at a time.
What does any of this have to do with J2EE, or Java?
/gordon

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Lalit - 07 Sep 2006 16:05 GMT
> Does your device really "log in" to the server using telnet, or does
> it simply use a Socket to connect to a specific port on the server?
[quoted text clipped - 16 lines]
>
> What does any of this have to do with J2EE, or Java?
Ya, device directly login to server....I can not configure the device
as it is provided by a vendor so it only works with telnet.
I have to transfer the info send by this device finally to my J2EE
application server which is on the same machine (on which Telnet Server
is running) and then pass on to the web client of J2EE application..
So script is just one part i have to do to integrate this device with
my application
Martin Gregorie - 07 Sep 2006 20:02 GMT
>> #!/bin/sh
>> echo "$1" >>barcode_file
[quoted text clipped - 12 lines]
> 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.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Lalit - 08 Sep 2006 15:08 GMT
Thanks Martin,
Things are moving ahead because of your Idea. I have configured my
wireless device with a prefix for invoking script. And am able to
capture data on the server.
Now the next task is to reflect this data through J2EE app server to
the Web Client who is waiting for it.