Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
kiranhiremath@gmail.com - 22 May 2006 11:45 GMT
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
Philipp Leitner - 22 May 2006 12:01 GMT
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

kiranhiremath@gmail.com schrieb:
> Hi,
>
[quoted text clipped - 10 lines]
> Regards,
> Kiran H
Martin Gregorie - 22 May 2006 13:50 GMT
> Hi,
>
[quoted text clipped - 5 lines]
> 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.

Signature

martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

kiranhiremath@gmail.com - 22 May 2006 14:23 GMT
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
Martin Gregorie - 22 May 2006 23:48 GMT
> Hi,
>
[quoted text clipped - 7 lines]
> 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.

Signature

martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

kiranhiremath@gmail.com - 23 May 2006 15:18 GMT
Thank You all for the reply.
I will build upon the sample codes.

Regards,
Kiran H


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.