LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 12-10-2009, 05:04 AM   #1
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 635

Rep: Reputation: 35
Wrapper script for alienBob's rsync_slackware_patches.sh ?


Hi,

I'm currently running rsync_slackware_patches.sh -q against the local mirror on a nightly basis and normally (when there's no patches) it outputs nothing, and when there is a patch, it outputs that entry in the changelog.

What is the best way to approach writing a wrapper-script around the rsync-script in order to email the output of the downloaded patches to me when something is changed and keep quiet when no news?

-y1
 
Old 12-10-2009, 05:06 AM   #2
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 581

Rep: Reputation: 114Reputation: 114
Personally I'd just wrap it up in some perl. Pretty easy to do. Just looking for the last perl email script I wrote..
 
Old 12-10-2009, 05:11 AM   #3
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 581

Rep: Reputation: 114Reputation: 114
Code:
#!/usr/bin/perl

if(dosomelogic()) {
  emaillog();
};


sub emaillog
{
        my $sendmail = "/usr/bin/sendmail -t";
        my $from     = "From: Foo <foo@example.com>\n";
        my $reply_to = "Reply-to: foo\@example.com\n";
        my $subject  = "Subject: Foo output of foo \n";
        my $content  = "\n";
        my $to       = "To: foo\@example.com\n";
        my $cc       = "Cc: bar\@example.com\n";
        my $file     = "/path/to/file/to/email/as/attachment.txt";

        open(FILE, $file) or die "Cannot open attachment";
        while ( <FILE> )
        {
                $content = $content . $_;
        }
        close(FILE);


        open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
        print SENDMAIL $from;
        print SENDMAIL $reply_to;
        print SENDMAIL $subject;
        print SENDMAIL $to;
        print SENDMAIL $cc;
        print SENDMAIL "Content-type: text/plain\n\n";
        print SENDMAIL $content;
        close(SENDMAIL);
}
Then you just need some logic to test whether whatever change you want to test for is present, and call emaillog().

Last edited by zordrak; 12-10-2009 at 05:13 AM.
 
Old 12-10-2009, 07:05 AM   #4
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,112

Rep: Reputation: Disabled
Quote:
Originally Posted by Yalla-One View Post
Hi,

I'm currently running rsync_slackware_patches.sh -q against the local mirror on a nightly basis and normally (when there's no patches) it outputs nothing, and when there is a patch, it outputs that entry in the changelog.

What is the best way to approach writing a wrapper-script around the rsync-script in order to email the output of the downloaded patches to me when something is changed and keep quiet when no news?

-y1
It is very easy. I run this script as a cron job every night. One nice feature of cron is that it will capture the output from the programs it runs and sends that text per email to the user account who runs the job.

No need for wrappers.

If root runs that script, then you can add an read mail address as email alias for root in /etc/mail/aliases (and run the command "newaliases" after the edit).

Eric
 
1 members found this post helpful.
Old 12-10-2009, 07:18 AM   #5
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 581

Rep: Reputation: 114Reputation: 114
^ And that is why alienBOB is the Dutch word for God
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Wrapper Script for vmware commands LXer Syndicated Linux News 0 10-11-2009 08:50 PM
question about rsync_slackware_patches.sh JosephS Slackware 4 02-22-2009 01:58 PM
Bash: how to write a wrapper script? J_Szucs Programming 0 01-29-2005 05:50 PM
Wrapper needed for BASH Script outspoken Programming 0 01-12-2005 09:04 AM
server wrapper script yapp Programming 2 08-02-2003 11:09 AM


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