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

Discussion in 'Java' started by kiranhiremath@gmail.com, May 22, 2006.

  1. Guest

    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
    , May 22, 2006
    #1
    1. Advertising

  2. Re: Java Program should open a telnet session and login to Unix serverusing a valid user id and password

    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

    schrieb:
    > 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, May 22, 2006
    #2
    1. Advertising

  3. Re: Java Program should open a telnet session and login to Unix serverusing a valid user id and password

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


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
    Martin Gregorie, May 22, 2006
    #3
  4. Guest

    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
    , May 22, 2006
    #4
  5. Re: Java Program should open a telnet session and login to Unix serverusing a valid user id and password

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


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
    Martin Gregorie, May 22, 2006
    #5
  6. Guest

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

    Regards,
    Kiran H
    , May 23, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vinay
    Replies:
    4
    Views:
    16,162
    vinay
    Jul 28, 2006
  2. vinay
    Replies:
    2
    Views:
    4,002
    =?ISO-8859-2?Q?Dra=BEen_Gemi=E6?=
    Jul 28, 2006
  3. Jim Isaacson
    Replies:
    5
    Views:
    603
    Default User
    Nov 5, 2004
  4. Tony Johansson
    Replies:
    3
    Views:
    16,204
    Patrice
    Jan 2, 2010
  5. Carcarius
    Replies:
    0
    Views:
    294
    Carcarius
    Dec 6, 2007
Loading...

Share This Page