LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 11-06-2008, 11:43 PM   #1
cgcamal
Member
 
Registered: Nov 2008
Location: Tegucigalpa
Posts: 78

Rep: Reputation: 16
Telnet automatically every 15 minutes


Hi experts,

Maybe somebody knows the answer:

Is possible to configurate a telnet session every certain
time(every 15 minutes for example) and after every connection
execute a script?

I dont know how, but something like:

Code:
******************************************
Every 15 minutes

   Telnet XXX.XXX.XXX.XXX
   user: myuser
   pwd:  mypwd

   run script.txt

Disconnet
******************************************
Thanks for any suggestion you could give me.

Best regards
 
Old 11-07-2008, 01:46 AM   #2
allez
Member
 
Registered: Jul 2008
Location: Russia/Siberia/Krasnoyarsk
Distribution: SuSE, CentOS, FreeBSD
Posts: 77

Rep: Reputation: 21
You may use expect utility in shell script, or Net::Telnet module if you use Perl.
 
Old 11-07-2008, 09:01 AM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
If you have a fast and reliable connection (that is, both computers are in the same LAN), you could use this:

Code:
cat input_file.txt | netcat your_host 23
The contents of input_file.txt is:
Code:
username
password
command1
command2
command3
exit
Looking at the code after a few years I am surprised that it still works. I used the first line (cat input...) in another script to check if a wireless router had still an RF connection. If not, I would reset it. There is a REQUIREMENT that the host you are telnetting to is there and responding. The script I am talking about which did the checking and contains the line (cat input...) I called with cron every 15 minutes. Standard rule: if intervals are below 2 minutes, use a loop and sleep, over 2 minutes, use crontab.

If your connection is not reliable or the host is not always there, use Expect. Tricky to learn Tcl/Expect, but there are plenty of examples around.

jlinkels
 
Old 11-07-2008, 10:49 PM   #4
cgcamal
Member
 
Registered: Nov 2008
Location: Tegucigalpa
Posts: 78

Original Poster
Rep: Reputation: 16
Thanks allez and jlinkels for your answers,

IŽll try what youŽve said to me.

Best regards
 
Old 11-26-2008, 12:06 PM   #5
nehaandrew
Member
 
Registered: Nov 2008
Posts: 53

Rep: Reputation: 15
There are multiple auto login scripts available on the net. You can configure your .profile file to run a script each time you login.

I believe coupling the above two ideas - you can build the solution you need.


Linux

Last edited by nehaandrew; 11-30-2008 at 01:21 AM.
 
  


Reply



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
Automatically Disconnecting Users After Five Minutes Idle Time kaplan71 Linux - Server 3 05-21-2008 10:13 PM
ssh/telnet coonecting and dropping automatically? bkpuser Linux - Newbie 1 12-18-2007 07:07 AM
Can't end telnet servcie in xinetd when close remote telnet cliend forcely zeroneworld Linux - Newbie 2 12-09-2007 08:47 PM
Can't end telnet servcie in xinetd when close remote telnet cliend forcefully. zeroneworld Linux - General 1 12-06-2007 07:17 AM
A ksh script to connect to telnet automatically? bijit1709 Programming 3 04-11-2007 11:30 PM

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

All times are GMT -5. The time now is 03:52 PM.

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