LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-15-2012, 03:19 AM   #1
aocferreira
Member
 
Registered: Feb 2011
Posts: 117

Rep: Reputation: 0
shell script 2 telnet!


Hello guys,

I have a shell script that's really simple and nothing dynamic: it only connects to a telnet session, executes cmd 1, waits x seconds, cmd 2, x seconds, etc...

Now, I want to do something like this: whenever I connect via telnet and execute the command, if I have certain output, I want to send an e-mail. But it's important to notice that I don't want to receive email if I have output "X", and 60 seconds after (for example) if I run the same script and have the same output also receive the e-mail... What do you think is the best approach to this problem ?
It's difficult?

Regards,
André
 
Old 11-15-2012, 11:46 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Test lock file existence / epoch time stamp contents?
 
Old 11-15-2012, 08:40 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
The expect command would be useful. It could run the telnet session and analyse it's output. When expect identifies an output that you want to trigger an email it could either run a program that sends the email or send output down a pipeline to a program that sends the emails.

The program that sends the emails needs to remember when it last sent an email corresponding to each output. Depending on how frequent the outputs are and how often the system is re-initialised the remembering could be either within the program or in a database. For ease, the per-output timestamps would be in seconds since the epoch began.

Again depending on how frequent the outputs are, and on available programming skills, the program could be in awk, shell script, perl, python, ruby etc.
 
  


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
shell script to automate TELNET daggulasreedhar Programming 5 08-02-2007 12:13 PM
can we telnet the system using shell script suchi_s Programming 18 02-18-2005 02:43 PM
PB launching shell-script with telnet Naurore LinuxQuestions.org Member Success Stories 1 08-04-2003 07:42 AM
PB launching shell-script with telnet Naurore Linux - Newbie 1 08-04-2003 04:45 AM
telnet login via shell script lethe Linux - General 8 05-13-2002 09:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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