1752767 Members
5124 Online
108789 Solutions
New Discussion юеВ

telnet question

 
SOLVED
Go to solution
yatin
Frequent Advisor

telnet question

How can i give all inputs to telnet through a file something like say telnet feeder
telnet_feeder usernm passwd file_containing_set of_commands
7 REPLIES 7
Joseph Loo
Honored Contributor

Re: telnet question

hi,

sorry, do not quite understand what you are trying to do. please explain more.

regards.
what you do not see does not mean you should not believe
yatin
Frequent Advisor

Re: telnet question

I am writing a shell script which will accept take following parameters:
1)hostname
2)username
3)password
5)input file this contains commands to be executed on remote machine.
This script will telnet the hostname and login using username and password and then execute the commands containing in the file
Franky_1
Respected Contributor
Solution

Re: telnet question

Hi,

if my understanding for your question is correct then try the following :

REMOTE=hostname #or IP address
(sleep 5
echo username
sleep 5
echo password
sleep 15
echo "ls -ald /tmp" #Your command
sleep 5
echo exit) |telnet $REMOTE

This should do the trick

Thanks

Franky
Don't worry be happy
Mark Grant
Honored Contributor

Re: telnet question

Any particular reason you can't use "remsh", "rexec" or "ssh"?
Never preceed any demonstration with anything more predictive than "watch this"
Bharat Katkar
Honored Contributor

Re: telnet question

See if this works with following:
echo "Enter Hostname :"
read VAR1
echo "Enter Username"
read VAR2
echo " Enter command to execute :\n"
read VAR3
remsh $VAR1 -l $VAR2 $VAR3

This will not ask you for password but verify for the username and also you need to
.rhosts files for the same.

Thought could be an simpler solution but security issue is still there.



You need to know a lot to actually know how little you know
Nicolas Dumeige
Esteemed Contributor

Re: telnet question

Hello,

Look for "expect", it expect for certain reply from the remote host before issuing another order.

Ant - the java make utility - is also capable of this.

Cheers

Nicolas
All different, all Unix
Franky_1
Respected Contributor

Re: telnet question

Hi yatin,

what do you think about assigning points ?

Thanks

Franky
Don't worry be happy