LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-04-2010, 08:43 AM   #1
Norwood
Member
 
Registered: Feb 2010
Location: A Smidge South O' Boston
Distribution: Debian
Posts: 41

Rep: Reputation: 15
Challenging script (for me at least!) Calling all scripters!


I need to make a cronjob do the following:

  • telnet to a remote computer every Thursday
  • execute a command
  • print the output of that command to a file
  • mail that file to my local machine
  • have the contents of that message pop up on my screen like xmessage or something.

The reason I need to do this is because the remote machine is a tape backup machine that has many running jobs on it.

Towards the end of the week I need to start pulling tapes as soon as the last job is finished. Time is of the essence because there can be hundreds of tapes some weeks.

What I do now is simply telnet to the machine, run the command and see if the jobs are finished.

I would just like to automate that process.

Last edited by Norwood; 03-04-2010 at 08:45 AM.
 
Old 03-04-2010, 09:12 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
can't you set the remote machine to tell you when it's finished all jobs ?

Last edited by smoker; 03-04-2010 at 09:15 AM.
 
Old 03-04-2010, 09:21 AM   #3
Norwood
Member
 
Registered: Feb 2010
Location: A Smidge South O' Boston
Distribution: Debian
Posts: 41

Original Poster
Rep: Reputation: 15
I think that's what I'm trying to do, no?
 
Old 03-04-2010, 09:36 AM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Quote:
Originally Posted by Norwood View Post
I think that's what I'm trying to do, no?
No.
You want to :
  • telnet to a remote computer every Thursday
  • execute a command
  • print the output of that command to a file
  • mail that file to my local machine
  • have the contents of that message pop up on my screen like xmessage or something.

I'm suggesting :

remote computer emails you when it's finished all jobs.

No telnet, no executing commands, no printing to files.

Surely the remote machine has some capabilities itself ?
 
Old 03-04-2010, 09:56 AM   #5
Norwood
Member
 
Registered: Feb 2010
Location: A Smidge South O' Boston
Distribution: Debian
Posts: 41

Original Poster
Rep: Reputation: 15
That would be one solution. However, the solution I'm asking is the one I would prefer.
 
Old 03-06-2010, 04:41 PM   #6
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Rep: Reputation: 41
Quote:
Originally Posted by Norwood View Post
That would be one solution. However, the solution I'm asking is the one I would prefer.
are you stuck with telnet or is ssh an option? ssh would be easier, else you need to use expect/tcl or perl.
 
Old 03-07-2010, 08:01 AM   #7
Norwood
Member
 
Registered: Feb 2010
Location: A Smidge South O' Boston
Distribution: Debian
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by trey85stang View Post
are you stuck with telnet or is ssh an option? ssh would be easier, else you need to use expect/tcl or perl.
Telnet's all I've got.
 
Old 03-07-2010, 01:00 PM   #8
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Rep: Reputation: 41
Quote:
Originally Posted by Norwood View Post
Telnet's all I've got.
id help you write it but it's going to take some time...

Check out expect, You can write a small expect script to open the telnet session, run your command give you the output, then logout of the telnet session.

Then you can process the information in a bash script.

This link has expect examples for running a telnet session.
http://www.osix.net/modules/article/?id=30

last, if you know perl you could do all this in one perl script.
 
Old 03-07-2010, 03:35 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,661

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by Norwood View Post
Telnet's all I've got.
We'd be glad to help you. Post what you've written so far, and where you're getting stuck.
 
  


Reply

Tags
crontab, scripting



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling perl script and passing variable from php script hosea Programming 5 10-21-2008 08:01 AM
how to pass a variable from a called script back to the calling script steven.c.banks Linux - General 2 05-05-2008 02:00 PM
Any kdialog scripters here? dive Programming 3 06-24-2007 09:53 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
calling another script to be run. sonesay Programming 2 05-23-2004 06:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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