Java Program should open a telnet session and login to Unix server using a valid user id and passwor

K

kiranhiremath

Hi,

I wanted to write a Java Program which will login ( using Telnet ) to a
Unix Server ( Ex: Solaris, Red Hat Linux) and issue some commands in
the Solaris.

The Java Program should be written in Windows machine.
If the java program is executed, then commands like cat or rm should be
executed in the unix server.

Any Help ??

Regards,
Kiran H
 
P

Philipp Leitner

Hi,

are you sure you actually need /telnet/ to do the job? Will simply
opening a socket, and writing the commands to the output stream of that
socket, not do?

You you really need to go for the external telnet command you should
look for the various java.lang.Runtime.exec() methods in the Java API.
These allow you to issue an external command.

/philipp
 
M

Martin Gregorie

Hi,

I wanted to write a Java Program which will login ( using Telnet ) to a
Unix Server ( Ex: Solaris, Red Hat Linux) and issue some commands in
the Solaris.

The Java Program should be written in Windows machine.
If the java program is executed, then commands like cat or rm should be
executed in the unix server.
- Why do you need to write a program?
- Does it have to run a built-in sequence of commands?
- Why can't you do the job with a standard telnet client for Windows?

The easy way to run commands via Telnet is to use the excellent (and
free) PuTTY telnet/ssh client and, if needed, run a shell script on the
*NIX system.

If you have to write a special-purpose Java client you can use a simple
Socket instance to talk to telnetd, the Telnet server. Read RFC 854,
available from http://www.ietf.org/rfc.html - I think that's the latest
Telnet protocol definition.

Be aware, too, that telnet is now deprecated due to insecurity. Use of
ssh is preferred. Besides, ssh can forward X.11 sessions, so you can run
GUI clients remotely via ssh provided you have an X-server running on
your Windows box.
 
K

kiranhiremath

Hi,

I have an application which uses JAVA JDK 1.4.
I need the Java Program to act as an Unix administrator.
i.e the Java program should be able to add, modify, delete users and
groups etc in the Unix Server.

Anyone has a sample code which will login to Unix machine and execute
the commands and get the results back.
A Socket program or any such code which can execute Shell commands is
OK.

Regards,
Kiran H
 
M

Martin Gregorie

Hi,

I have an application which uses JAVA JDK 1.4.
I need the Java Program to act as an Unix administrator.
i.e the Java program should be able to add, modify, delete users and
groups etc in the Unix Server.

Anyone has a sample code which will login to Unix machine and execute
the commands and get the results back.
A Socket program or any such code which can execute Shell commands is
OK.
As I said, you have to act like a telnetd client: telnetd uses a pseudo
tty to simulate a login from a serial device. This login starts a shell
to execute your commands. Read the RFC I suggested to find out how to
talk to telnetd OR find an open source telnet client and read its
source. There are Java implementations: see
http://javatelnet.org/space/start

Much the same applies to ssh / sshd, i.e. it uses the same pseudo tty
mechanism. There are Java implementations for ssh too: see
http://www.openssh.com/java.html

As for the user maintenance commands, look at the manpages for useradd,
userdel and usermod. They are standard for Linux and, IIRC, for SVR4 *NIXen.
 
K

kiranhiremath

Thank You all for the reply.
I will build upon the sample codes.

Regards,
Kiran H
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top