• 1 reply
  • Latest Post - ‏2011-06-01T22:39:17Z by SystemAdmin
1 Post

Pinned topic How to auto telnet the server from another server?

‏2011-05-30T06:57:25Z |
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" < 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" < a.txt
) | telnet B

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

guys please help me...
Updated on 2011-06-01T22:39:17Z at 2011-06-01T22:39:17Z by SystemAdmin
  • SystemAdmin
    549 Posts

    Re: How to auto telnet the server from another server?

    Hi Atul,

    There are Several ways to achieve this.

    #1. This can be achieved directly using ssh command as
    ssh <command>

    #2. As you have mentioned you have only telnet login method to
    B. Assuming that you have expect S/w installed in A

    spawn telnet <machinename>
    expect "login:"
    send "<loginID>\r"
    expect "Password:"
    send "<password>\r"
    send "ls -l > fileName"
    send "mail -x ..."

    will do the Magic ...

    There are other ways too....

    Sivaswami Jeganathan