AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only
Expand all | Collapse all

How to auto telnet the server from another server?

  • 1.  How to auto telnet the server from another server?

    Posted Mon May 30, 2011 02:51 AM

    Originally posted by: Atul.Singh


    Hi All,
    I have a problem with auto telnet script, but I want to tell u something
    a) I am only a member access on the server, so not able to access 'root' account
    b) not able to install any software on server
    3) On server, there is not install 'except'

    I have to write a script, which is ran from A server, login/telnet to B server, do 'ls -lrt' and send to me the output via mail.

    I have only basic stucture....

    run from Server A
    1) login to B
    2) cd landing path
    3) ls -l > a.txt
    4) mail -s "Status" user@domain.com < a.txt
    5) connection closed

    I tried this code.....
    run from Server A
    (
    echo user
    sleep 1
    echo password
    sleep 1
    cd landing_zone
    ls -l > a.txt
    mail -s "Status" user@domail.com < a.txt
    ) | telnet B

    But this script return the ls of Server A but I want the Server B

    guys please help me...
    #AIX-Forum


  • 2.  Re: How to auto telnet the server from another server?

    Posted Mon May 30, 2011 06:05 AM


  • 3.  Re: How to auto telnet the server from another server?

    Posted Mon May 30, 2011 07:53 AM

    Originally posted by: Atul.Singh


    thanks for your help.. But on my server except is not installed, so I can not use this. Please share your thoughts

    thanks
    #AIX-Forum


  • 4.  Re: How to auto telnet the server from another server?

    Posted Mon May 30, 2011 09:44 AM

    Originally posted by: PontiacGeronimo


    I don;t know if it will be helpfull but you can try to copy expect from another AIX where you have it installed into your home directory.

    from existing server I copied 3 files:
    expect
    libexpect5.45.so
    libtcl8.5.so

    to ~/expect directory (located in none root user home)

    and 1 file:
    init.tcl
    to ~/library (located in the same, none root user home)

    
    $ pwd /home/utest $ ls -ld exp* lib* drwxr-xr-x    2 utest  staff            256 May 30 13:24 expect drwxr-xr-x    2 utest  staff            256 May 30 13:28 library $ ls exp* lib* expect: expect            libexpect5.45.so  libtcl8.5.so   library: init.tcl $ LIBPATH=/home/utest/expect expect/expect expect1.1> help   If available, you can refer to the Base Document Library 
    
    for general assistance.   Some basic Commands are:   man -k keyword      - lists commands relevant to a keyword man command         - prints out the manual pages 
    
    for a command cat                 - concatenates files (and just prints them out) vi                  - text editor ls                  - lists contents of directory mail                - sends and receives mail passwd              - changes login password sccshelp            - views information on the Source Code Control System smit                - system management 
    
    interface tool tset                - sets terminal modes who                 - who is on the system write               - writes to another user   To find programs about mail, use the command:           man -k mail and print out the man command documentation via:        man mail You can log out of the system by typing:                exit   expect1.2> exit $ LIBPATH=/home/utest/expect ldd expect/expect expect/expect needs: /home/utest/expect/libexpect5.45.so /usr/lib/libpthreads.a(shr_comm.o) /usr/lib/libpthreads.a(shr_xpg5.o) /usr/lib/threads/libc.a(shr.o) /usr/lib/librtl.a(shr.o) /home/utest/expect/libtcl8.5.so /unix /usr/lib/libcrypt.a(shr.o) /usr/lib/libpthread.a(shr_xpg5.o) /usr/lib/libpthread.a(shr_comm.o) /usr/lib/libdl.a(shr.o) $
    

    #AIX-Forum


  • 5.  Re: How to auto telnet the server from another server?

    Posted Mon May 30, 2011 10:35 AM

    Originally posted by: PontiacGeronimo


    btw. I checked expect I copied (not installed) to non-root user direcotry (described above) and a sample autotelnet-expect script worked fine:

    
    $ pwd /home/utest $ export LIBPATH=/home/utest/expect $ cat expect_telnet.exp #!/home/utest/expect/expect spawn telnet localhost expect 
    "login:" send 
    "auser\n" expect 
    "Password:" send 
    "auser\n" send 
    "cd /opt\n" send 
    "ls -ltr\n" interact   $ ./expect_telnet.exp spawn telnet localhost Trying... Connected to loopback. Escape character is 
    '^]'.     telnet (testhost)     AIX Version 5 Copyright IBM Corporation, 1982, 2008. login: auser auser
    's Password:   Test system. Test system. Test system.   Last unsuccessful login: Mon May 30 14:11:20 CUT 2011 on /dev/pts/1 from loopback Last login: Mon May 30 14:27:25 CUT 2011 on /dev/pts/2 from loopback   $ cd /opt $ ls -ltr total 24 drwxr-xr-x    3 root     system          256 Nov 23 2005  IBM drwxr-xr-x    4 root     system          256 Oct 25 2007  IBMinvscout drwxr-xr-x    3 root     system          256 Jan 30 2008  perl drwxr-xr-x    3 root     system          256 Jan 30 2008  cam drwxr-xr-x    3 root     system          256 Jan 30 2008  hsc drwxr-xr-x    8 bin      bin             256 Jun 24 2008  diagnostics drwxrwxr-x   13 root     system         4096 Jun 24 2008  freeware drwxr-xr-x   12 bin      bin            4096 Jun 24 2008  csm drwxr-xr-x    2 root     system         4096 Jun 24 2008  filepath drwxr-xr-x    2 root     system          256 Mar 10 17:16 lost+found $
    

    #AIX-Forum


  • 6.  Re: How to auto telnet the server from another server?

    Posted Tue May 31, 2011 03:34 AM

    Originally posted by: Atul.Singh


    Thanks a lot man ..........

    I'll try your method, I think this will work for me... I will let u know when I m done..

    Thanks
    Atul Singh
    #AIX-Forum


  • 7.  Re: How to auto telnet the server from another server?

    Posted Tue May 31, 2011 10:53 AM

    Originally posted by: Atul.Singh


    Hi Man...

    Can you please send me these files in mail... so that I can also try this...
    my mail id is : atul9806@gmail.com

    thanks
    Atul Singh
    #AIX-Forum


  • 8.  Re: How to auto telnet the server from another server?

    Posted Wed June 01, 2011 04:18 AM
      |   view attached

    Originally posted by: PontiacGeronimo


    in the attachememnt you will find:

    
    drwxr-xr-x    2 utest    staff           256 May 30 13:24 expect -rwx------    1 utest    staff           169 Jun  1 08:13 expect_telnet.exp drwxr-xr-x    2 utest    staff           256 May 30 13:28 library
    


    extract them to a home directory, set LIBPATH and check.
    #AIX-Forum

    Attachment(s)



  • 9.  Re: How to auto telnet the server from another server?

    Posted Wed June 01, 2011 09:58 AM

    Originally posted by: Atul.Singh


    Hi Buddy

    this is the structure where I extract the file u provided

    atsingh5 > pwd
    /auto/home/atsingh5/AUTOTEST
    atsingh5 > ls -l
    total 4120
    drwx------ 2 atsingh5 staff 256 May 30 13:24 expect
    -rw------- 1 atsingh5 staff 2099200 Jun 01 13:40 expect_.tar
    -rwx------ 1 atsingh5 staff 203 Jun 01 13:50 expect_telnet.exp
    drwx------ 2 atsingh5 staff 256 May 30 13:28 library

    What should I set the new PATH ?? I am little bit confused ??
    I think there is not any LIBPATH exist in AIX ?? only PATH variable is exist. Please correct me if I am wrong
    #AIX-Forum


  • 10.  Re: How to auto telnet the server from another server?

    Posted Wed June 01, 2011 10:01 AM

    Originally posted by: Atul.Singh


    I added this line in PATH

    
    echo $PATH /auto/home/atsingh5/AUTOTEST/expect:/home/atsingh5/expect:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java14/jre/bin:/usr/java14/bin:/usr/java131/jre/bin:/usr/java131/bin:/usr/lib/instl:/usr/local/bin:/usr/es/sbin/cluster/utilities
    


    when I fired the query, I got these errors
    
    ./expect_telnet.exp exec(): 0509-036 Cannot load program /auto/home/atsingh5/AUTOTEST/expect/expect because of the following errors: 0509-150   Dependent module libexpect5.45.so could not be loaded. 0509-022 Cannot load module libexpect5.45.so. 0509-026 System error: A file or directory in the path name does not exist.
    


    please guide
    #AIX-Forum


  • 11.  Re: How to auto telnet the server from another server?

    Posted Wed June 01, 2011 03:28 PM

    Originally posted by: PontiacGeronimo


    knowing that you put library and expect directories to /auto/home/atsingh5/AUTOTEST

    try

    export LIBPATH=/auto/home/atsingh5/AUTOTEST/expect
    before executing ./expect_telnet.exp
    I hope that's all to do.
    #AIX-Forum


  • 12.  Re: How to auto telnet the server from another server?

    Posted Mon May 30, 2011 10:20 AM

    Originally posted by: PontiacGeronimo


    btw. the easiest way would be to use ssh instead of telnet.

    don't you considere ssh as well?
    #AIX-Forum


  • 13.  Re: How to auto telnet the server from another server?

    Posted Tue May 31, 2011 03:33 AM

    Originally posted by: Atul.Singh


    thanks man...
    but for using I have to create the public keys on both servers that's why I tried to avoid the ssh, if u have any idea abt ssh please share.

    thanks
    Atul Singh
    #AIX-Forum


  • 14.  Re: How to auto telnet the server from another server?

    Posted Thu June 02, 2011 01:53 AM

    Originally posted by: Atul.Singh


    thanks man !!! it worked ...... :-)

    May I know ur good name please ???
    and one thing more, why we set the LIBPATH ?? (As I understand, it helps to find the library of expect but Is it not possible to set in PATH variable ??)
    I did not heard abt this type of variable. Please share your comment.

    Thanks a lot !!
    Atul Singh
    #AIX-Forum