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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
02-17-2005, 11:58 PM
|
#1
|
Member
Registered: May 2004
Posts: 133
Rep:
|
can we telnet the system using shell script
code to telnet the system and pass user name and password through shell script.. is it possible?
it can be done using expect..
is it possible through shell script
|
|
|
02-18-2005, 02:26 AM
|
#2
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
Hi,
This are 2 ways of doing it:
1) using a HERE document
Code:
telnet some.site.com <<-HERE
command
command
.
.
command
exit
HERE
Everything between HERE and HERE is given to telnet and executed by telnet.
2) Echoing to telnet
Code:
{
echo "command"
echo "command"
echo "exit"
} | telnet some.site.com
Hope this gets you going again.
|
|
|
02-18-2005, 02:35 AM
|
#3
|
Member
Registered: Oct 2003
Location: Chennai
Distribution: Slackware 12.1
Posts: 165
Rep:
|
I dont thing we can pass the password and login through telnet ( even if this is possible, I guess its not a very good idea at all !) The only way we can do this is by using .netrc file in $HOME/.netrc.
The format of a .netrc file
Code:
machine xxx.x.com
login xxx
password xxxxx
|
|
|
02-18-2005, 02:39 AM
|
#4
|
Member
Registered: May 2004
Posts: 133
Original Poster
Rep:
|
how to do with .netrc file.. what all i have to do
|
|
|
02-18-2005, 02:45 AM
|
#5
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
Hi,
@Libu: I don't have telnet (client/sserver) installed, so I could not try it out, but it works for sql/ftp including the user/password part (on the other hand it does not for ssh).
I do agree that telnet is unsave and shouldn't be used, but that was not the question the OP asked  And even a .netrc file is unsave.
The .netrc solution you (Libu) gave is an elegant way of doing it. Although I don't know if it'll work for telnet, never tried. It does for ftp, that's for sure.
|
|
|
02-18-2005, 02:46 AM
|
#6
|
Member
Registered: May 2004
Posts: 133
Original Poster
Rep:
|
how to create this file it does not reside in home
|
|
|
02-18-2005, 02:49 AM
|
#7
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
Hi,
Use you fav editor and create it:
vi ~/.netrc
fill it with the appropriate commands (machine xxx.x.com, login xxx, password xxxxx) each on its own line.
Hope this helps.
|
|
|
02-18-2005, 02:53 AM
|
#8
|
Member
Registered: May 2004
Posts: 133
Original Poster
Rep:
|
how to run it.. does it do the file transfer and how ?
what is the complete procedure?
|
|
|
02-18-2005, 02:56 AM
|
#9
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795
|
.netrc is for ftp only and doesn't apply to telnet (as far as I know).
There's a .telnetrc file, but not suitable to pass credentials
You should use rlogin/rsh instead, or better ssh which all allow non-interactive login.
|
|
|
02-18-2005, 03:08 AM
|
#10
|
Member
Registered: May 2004
Posts: 133
Original Poster
Rep:
|
can i ftp a system through some gateway
|
|
|
02-18-2005, 03:21 AM
|
#11
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795
|
Yes, you can ftp to a system through either an http or a socks proxy.
PS: You should have better started another thread as this last question has nothing to do with the initial one.
|
|
|
02-18-2005, 03:22 AM
|
#12
|
Member
Registered: Oct 2003
Location: Chennai
Distribution: Slackware 12.1
Posts: 165
Rep:
|
Oops, yes the .netrc was for ftp and not telnet  . I overlooked that. Sorry for wasting your time.
As for telnet, using expect is the only answer that I can think off ! Dont know of anyother way, you can automate logging to another machine through telnet.
Last edited by Libu; 02-18-2005 at 03:24 AM.
|
|
|
02-18-2005, 03:23 AM
|
#13
|
Member
Registered: May 2004
Posts: 133
Original Poster
Rep:
|
i want to write the script which would first telnet the gateway from local system and then from gateway will do the ftp on other system
|
|
|
02-18-2005, 03:32 AM
|
#14
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795
|
Forget telnet and ftp.
Code:
ssh gateway scp othersystem:/somefile /somedir
|
|
|
02-18-2005, 03:34 AM
|
#15
|
Member
Registered: May 2004
Posts: 133
Original Poster
Rep:
|
i dint get it..
how to do?
|
|
|
All times are GMT -5. The time now is 06:14 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|