1846028 Members
3263 Online
110253 Solutions
New Discussion

telnet scripts ??

 
SOLVED
Go to solution
someone_4
Honored Contributor

telnet scripts ??

how would I start a script that would telnet into another box execute commands and exit the box .. any sugestions?
10 REPLIES 10
James R. Ferguson
Acclaimed Contributor
Solution

Re: telnet scripts ??

Richard:

I think what you are looking for is the "remote shell" (remsh) command. Look at the man pages for 'remsh'.

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: telnet scripts ??

Richard:

I think what you are looking for is the "remote shell" (remsh) command. Look at the man pages for 'remsh'.

...JRF...
Rita C Workman
Honored Contributor

Re: telnet scripts ??

I use remsh to execute remote commands on other boxes. Just make sure you have your rhosts file set up for this on the boxes.

Just a thought
Kofi ARTHIABAH
Honored Contributor

Re: telnet scripts ??

Richard:

That functionality is only available in either remsh or ssh. You cannot use telnet non-interactively. I would suggest you go with the ssh setup.
nothing wrong with me that a few lines of code cannot fix!
John McWilliams
Advisor

Re: telnet scripts ??

Richard - I use remote shell but to avoid being asked for a password you need to put a .rhosts file in the users home directory on the remoth machine that is excuting the command. enclose the command in double quotes too.
eg remsh HOST "ls -l /etc"

Regards John
John McWilliams
Advisor

Re: telnet scripts ??

Richard - I use remote shell but to avoid being asked for a password you need to put a .rhosts file in the users home directory on the remoth machine that is excuting the command. enclose the command in double quotes too.
eg remsh HOST "ls -l /etc"

Regards John
John McWilliams
Advisor

Re: telnet scripts ??

Richard - I use remote shell but to avoid being asked for a password you need to put a .rhosts file in the users home directory on the remoth machine that is excuting the command. enclose the command in double quotes too.
eg remsh HOST "ls -l /etc"

Regards John
Dan Hetzel
Honored Contributor

Re: telnet scripts ??

Hi,

remsh is the program you need, providing the
.rhosts file is set properly on the remote
host.

If you want to start an X11 executable
on the remote host, you can use xon as in
xon HOST /usr/bin/X11/xclock
xon will take care of your $DISPLAY
environment variable.

I'm using xon as an easy way to open
a new dtterm window on a remote host by
setting a few aliases in my .profile
for example:
alias sys01='/usr/contrib/bin/X11/xon
sys01 /usr/bin/X11/dtterm -name sys01 -ls'

Typing "sys01" will then open a new dtterm
window, named sys01 with a login shell on the
remote host (that's what the -ls is for)
My $DISPLAY environment variable will
be automatically set in this new window.

Don't forget the .rhosts file, it's needed

Dan

PS: xon is unsupported by HP but I've been
using it for years without any problem.
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Lasse Knudsen
Esteemed Contributor

Re: telnet scripts ??

Richard,

As others have indicated 'remsh' may be the program for you. You do not say what 'box' is so it might not have 'rsh' at all.

We use telnet scripts to login to e.g. routers and retrieve statistics etc.

You might want to look at a program called 'expect' (FreeWare) where you do differently depending on feedback.

A simple telnet script can be constucted doing something like this:

( sleep 2
echo guest
sleep 2
echo guestw
sleep 5
echo ls
sleep 5
echo exit ) | telnet host


The script logs into a host and executes 'ls'.

You need the sleep commands in order to be sure that the previous command has finished. ('expect' is a lot better on this point)
In a world without fences - who needs Gates ?
Ralph Grothe
Honored Contributor

Re: telnet scripts ??

Hi,

just to strengthen Perl's bashfully neglected position in this forum,
there is a splendid Module in CPAN for scripting automated telnet sessions.
Please, have a look at

http://www.cpan.org/modules/by-module/Net/Net-Telnet-3.02.readme

However, if not using Perl I'd go for ssh which is a much better replacement for rsh (which HP unconventionally called remsh, the other is restricted shell in HP lingo).

Madness, thy name is system administration