LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 12-27-2005, 08:57 AM   #1
Uday123
Member
 
Registered: Nov 2005
Posts: 80

Rep: Reputation: 15
auto-login script for connecting to remote m/n by using telnet/ftp/ssh


Hi all,

I need a script for getting connection to remote machine by using ssh/telnet/ftp.
and that script should do
1.copy the files/scripts from my machine to remote machine.
2.execute the script at remote machine and copy the output file from remote m/n to my local machine.

I have done with the connectivity part by using Expect script.
#!/usr/bin/expect -f
spawn telnet <IP address>
expect -re "login"
send "username\n"
expect -re "Password"
send "password of the user\n"
interact

Can you please help me for getting the other 2 requirements.

Thanks in advance
 
Old 12-27-2005, 09:51 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
this is just weird, i've seen like 5 expect questions today, and hardly any ever before...

anywho... firslty don't use telnet. secondsly use ssh, thirdly use preshared keys to mean you don't need to log in at all. you've no need to run expect at all.

ssh user@server mycommandiwanttorun > localoutputfile.txt
 
Old 04-13-2009, 01:10 PM   #3
mariusica_sb
LQ Newbie
 
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
RE: Auto Login with telnet

Quote:
Originally Posted by Uday123 View Post
Hi all,

I need a script for getting connection to remote machine by using ssh/telnet/ftp.
and that script should do
1.copy the files/scripts from my machine to remote machine.
2.execute the script at remote machine and copy the output file from remote m/n to my local machine.

I have done with the connectivity part by using Expect script.
#!/usr/bin/expect -f
spawn telnet <IP address>
expect -re "login"
send "username\n"
expect -re "Password"
send "password of the user\n"
interact

Can you please help me for getting the other 2 requirements.

Thanks in advance
Hi all

The Auto login part works great
I have been searching for days for a thing like that and this is the first one wich really worked
Good Script
10x
 
Old 01-21-2010, 05:03 AM   #4
pawan_linux
LQ Newbie
 
Registered: Jan 2010
Posts: 9

Rep: Reputation: 0
Unhappy hi freinds

The above autologin script is not working on my system.
the error is
spawn command not found
send command not found

am i Have to install these two programs prior to make this script runing?If yes,How?

please revert
 
Old 02-15-2011, 05:14 PM   #5
melk0r101
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Rep: Reputation: 0
Hi,

I made a free open source tool named SendCommand that would permit you to automate logins (ssh/telnet) and command execution on your routers. It has been developed in perl and it is highly customizable.

Check it out:
https://sourceforge.net/projects/sendcommand/

cheers
 
Old 10-12-2011, 11:31 AM   #6
floorripper
LQ Newbie
 
Registered: Oct 2011
Distribution: ubuntu 10.04
Posts: 25

Rep: Reputation: Disabled
COOL SCRIPT MAN! AWESOME!
I did this.

apt-get install expect
cd /usr/sbin


vi autologin

#!/usr/bin/expect -f
spawn telnet 10.149.100.3
expect -re "Username:"
send "iamuser\n"
expect -re "Password"
send "thebest\n"
interact

So we create a file, where we can specify an IP address of the remote machine, your password and username.
I am wondering how to make it dynamic for any ip like: autologin 10.10.1.1
 
  


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
Auto login with telnet taureanyang Programming 2 06-14-2005 01:33 AM
Remote Telnet Not connecting(Red Hat AS2.1) collierdb Linux - Networking 4 12-24-2003 08:28 AM
telnet auto-login anthjaz Linux - Networking 15 11-04-2003 01:28 PM
remote telnet/ssh sorcerer980 Linux - Newbie 3 07-03-2003 12:03 AM
Connecting to Telnet and FTP slow mastahnke Linux - Networking 4 03-25-2003 07:08 AM


All times are GMT -5. The time now is 04:54 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