LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Challenging script (for me at least!) Calling all scripters! (https://www.linuxquestions.org/questions/linux-general-1/challenging-script-for-me-at-least-calling-all-scripters-793169/)

Norwood 03-04-2010 08:43 AM

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.

smoker 03-04-2010 09:12 AM

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

Norwood 03-04-2010 09:21 AM

I think that's what I'm trying to do, no?

smoker 03-04-2010 09:36 AM

Quote:

Originally Posted by Norwood (Post 3885590)
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 ?

Norwood 03-04-2010 09:56 AM

That would be one solution. However, the solution I'm asking is the one I would prefer.

trey85stang 03-06-2010 04:41 PM

Quote:

Originally Posted by Norwood (Post 3885626)
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.

Norwood 03-07-2010 08:01 AM

Quote:

Originally Posted by trey85stang (Post 3888597)
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. :thumbsdown:

trey85stang 03-07-2010 01:00 PM

Quote:

Originally Posted by Norwood (Post 3889148)
Telnet's all I've got. :thumbsdown:

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.

TB0ne 03-07-2010 03:35 PM

Quote:

Originally Posted by Norwood (Post 3889148)
Telnet's all I've got. :thumbsdown:

We'd be glad to help you. Post what you've written so far, and where you're getting stuck.


All times are GMT -5. The time now is 04:15 PM.