LinuxQuestions.org
Review your favorite Linux distribution.
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 04-11-2007, 05:00 PM   #1
bijit1709
Member
 
Registered: Oct 2006
Location: Costa Rica, Escazu
Distribution: Slackware 12.0 (2.6.21.5)
Posts: 67

Rep: Reputation: 15
A ksh script to connect to telnet automatically?


How can I create a script so I can connect to a server using telnet and ssh? This is what I made but its says "Connection closed by foreign host."

#!/bin/ksh

telnet $host <<- EOF

user $users $pass

EOF

Thanks for any help!!
 
Old 04-11-2007, 06:04 PM   #2
cfaj
Member
 
Registered: Dec 2003
Location: Toronto, Canada
Distribution: Mint, Mandriva
Posts: 221

Rep: Reputation: 31
Quote:
Originally Posted by bijit1709
How can I create a script so I can connect to a server using telnet and ssh? This is what I made but its says "Connection closed by foreign host."

#!/bin/ksh

telnet $host <<- EOF

user $users $pass

EOF

It is much easier to use ssh than telnet, if you use host-based authentication. To use telnet, you need 'expect'.

 
Old 04-11-2007, 08:08 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
telnet should be avoided, it is a security risk. Use ssh, and set up public key authentication if you require passwordless logins. Once this is done, you can easily do things like this from a shell script:
Code:
ssh otherhost /home/me/bin/execute_program
to remote-execute a command on the remote host.
 
Old 04-11-2007, 11:30 PM   #4
bijit1709
Member
 
Registered: Oct 2006
Location: Costa Rica, Escazu
Distribution: Slackware 12.0 (2.6.21.5)
Posts: 67

Original Poster
Rep: Reputation: 15
Thanks for the advice regarding the telnet..I already removed it and now using ssh. Thanks for the quick posts this was my first post. And never thought I would get a quick reply.

Does any one has manuals for linux, unix, ksh, c, or any other Unix related stuff please send it to bijit1709@gmail.com it will be highly appreciated.
 
  


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
Ksh Script Help sharathkv25 Programming 10 02-02-2007 10:28 AM
help w/ksh script ShaqDiesel Programming 2 01-12-2007 02:04 PM
bash/ksh: Automatically send response to a program jimieee Programming 6 01-11-2007 05:45 PM
Can somebody help me with a ksh script? twentymil AIX 7 01-21-2004 09:55 AM
KSH script AquamaN Programming 2 12-08-2003 11:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:47 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration