LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-26-2009, 12:56 AM   #1
rahulruns
LQ Newbie
 
Registered: Feb 2008
Posts: 21

Rep: Reputation: 0
SHELL SCRIPT to automate telnet login


I am writing a SHELL SCRIPT (in ksh) to automate telnet login. What I have to do is I have the hostname and the ipaddress and I have to use command telnet <ipaddress>, but the command requires the username and password to login to the host. I need to write the script where the username and the password will already be provided and there will be no need to user intervention
 
Old 06-26-2009, 01:04 AM   #2
vap16oct1984
Member
 
Registered: Jun 2009
Location: INDIA
Distribution: RHEL-5
Posts: 174
Blog Entries: 3

Rep: Reputation: 38
i am not agreed for this is a security risk. i will suggest u pls go for ssh.

an write a script for ssh. its secure and no password is required once on generated the ssh an rsa keys.
 
Old 06-26-2009, 02:37 AM   #3
rahulruns
LQ Newbie
 
Registered: Feb 2008
Posts: 21

Original Poster
Rep: Reputation: 0
This is a configuration required to run particular stuff.
Could you suggest the method to automate the telnet login
 
Old 06-27-2009, 05:15 AM   #4
frater
Member
 
Registered: Jul 2008
Posts: 106

Rep: Reputation: 23
This is straight from my router which logins to my modem when it isn't able to ping the gateway.
My modem is configured in zipB but doesn't retain its settings after a reboot. This has been running for more than a year.....

Code:
(sleep 1; echo -e "admin\r"; sleep 1; echo -e "admin\r"; sleep 1; echo -e "zipb set public device WAN\r"; sleep 1; echo -e "user logout\r"; sleep 1; echo -e "exit\r") | telnet 172.19.3.1
It works great for telnet.
ssh doesn't work with the above example (as I found out). plink (ssh for windows) does work. I wrote something in bash for windows like that as well (to automatically configure modems)

If you want to do something more advanced, you should look at "expect"
It will give the appropriate commands at the right moment..

I just finished a script that automatically logins to routers and get their status. It does it using ssh or telnet.
I had a little problem with it, but could finally solve it.
I placed a question here...
Maybe you can get some info out of it...
http://www.linuxquestions.org/questi...t-in-it-735271
 
Old 06-27-2009, 06:11 AM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
There can be good reasons for passwordless telnet access. See: "telnet towel.blinkenlights.nl" for example.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How would I automate shell script startup during a reboot?? xmdms Linux - Newbie 19 10-22-2008 07:16 AM
shell script to automate TELNET daggulasreedhar Programming 5 08-02-2007 12:13 PM
Automate FTP session using Shell Script kalyanofb Programming 2 04-07-2007 08:44 AM
how to automate telnet login, script or something kiwibird Linux - Networking 2 11-09-2005 02:02 PM
telnet login via shell script lethe Linux - General 8 05-13-2002 09:31 AM


All times are GMT -5. The time now is 05:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration