summaryrefslogtreecommitdiff
path: root/utils/notify_short
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-04-26 18:00:56 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-04-26 18:00:56 +0000
commit666fd833584fe2e3618a397fe9d9a9bdf4c5b94b (patch)
tree19c4444705fd7f7803e0d7b597659c11d7e85b73 /utils/notify_short
parent2edd2e4de0f08a0a5f23647ea715f279671a0b89 (diff)
Doing a simple Perltidy commit so that I can evaluate differences between the branches and make sure patches are up to date
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1103 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'utils/notify_short')
-rw-r--r--utils/notify_short/config.pl8
-rw-r--r--utils/notify_short/listener.pl46
2 files changed, 29 insertions, 25 deletions
diff --git a/utils/notify_short/config.pl b/utils/notify_short/config.pl
index bd37bed1..cddda1e0 100644
--- a/utils/notify_short/config.pl
+++ b/utils/notify_short/config.pl
@@ -1,13 +1,12 @@
#!/usr/bin/perl
-use vars qw($email_to $cc_to $email_from $sendmail $database $db_user
- $db_passwd $template_head $template_foot);
+use vars qw($email_to $cc_to $email_from $sendmail $database $db_user
+ $db_passwd $template_head $template_foot);
# The address to send the mail to. On UNIX systems, multiple addresses can be
# separated by a space.
$email_to = 'manager@example';
-
# The email address this email is from:
$email_from = 'noreply@example';
@@ -28,8 +27,7 @@ $cycle_delay = 60;
# The password for the db user:
$db_passwd = "mypasswd";
-$template_top =
-"From: $email_from
+$template_top = "From: $email_from
Subject: Parts Short Notice
Hi. This is the SL-Short listener. You are receiving this message because
diff --git a/utils/notify_short/listener.pl b/utils/notify_short/listener.pl
index a9286795..acbb7c91 100644
--- a/utils/notify_short/listener.pl
+++ b/utils/notify_short/listener.pl
@@ -7,40 +7,46 @@
# By Chris Travers, Metatron Technology Consulting
# chris@metatrontech.com
#
-# Released under the GNU GPL v2.0 or later. See included GPL.txt for more
+# Released under the GNU GPL v2.0 or later. See included GPL.txt for more
# information.
require "config.pl";
use DBI;
my $dsn = "dbi:Pg:dbname=$database";
-my $dbh = DBI->connect($dsn, $db_user, $db_passwd,
- { AutoCommit => 1,
- PrintError => 0,
- RaiseError => 1, }
+my $dbh = DBI->connect(
+ $dsn, $db_user,
+ $db_passwd,
+ {
+ AutoCommit => 1,
+ PrintError => 0,
+ RaiseError => 1,
+ }
);
my $sth;
$dbh->do("LISTEN parts_short");
-while (1){ # loop infinitely
- if ($dbh->func ('pg_notifies')){
- &on_notify;
- }
- sleep $cycle_delay;
+while (1) { # loop infinitely
+ if ( $dbh->func('pg_notifies') ) {
+ &on_notify;
+ }
+ sleep $cycle_delay;
}
+
sub on_notify {
- open (MAIL, '|-', "$sendmail");
- $sth = $dbh->prepare("
+ open( MAIL, '|-', "$sendmail" );
+ $sth = $dbh->prepare( "
SELECT partnumber, description, onhand, rop FROM parts
WHERE onhand <= rop
- ");
- $sth->execute;
- print MAIL $template_top;
- while (($partnumber, $description, $avail, $rop) = $sth->fetchrow_array){
- write MAIL;
- }
- print MAIL $template_foot;
- close MAIL;
+ " );
+ $sth->execute;
+ print MAIL $template_top;
+ while ( ( $partnumber, $description, $avail, $rop ) = $sth->fetchrow_array )
+ {
+ write MAIL;
+ }
+ print MAIL $template_foot;
+ close MAIL;
}