[16310] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3722 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 10:33:04 2000

Date: Tue, 18 Jul 2000 07:32:55 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963930775-v9-i3722@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 18 Jul 2000     Volume: 9 Number: 3722

Today's topics:
        parsing cronjob emails ()
    Re: parsing cronjob emails (Clinton A. Pierce)
    Re: parsing cronjob emails ()
    Re: parsing cronjob emails ()
        pass change ()
    Re: pass change (jb)
        Passing and using multidimensional array references ()
    Re: Passing and using multidimensional array references (Lauren Smith)
    Re: Passing and using multidimensional array references (Jakob Schmidt)
    Re: Passing and using multidimensional array references (jason)
        Perl and Mysql (David Fleet)
        Perl and Mysql (David Fleet)
        Perl and Mysql (David Fleet)
        Perl and Mysql (David Fleet)
    Re: Perl and Mysql (Bernard El-Hagin)
    Re: Perl and Mysql (Thorbjørn Ravn Andersen)
    Re: Perl and Mysql (David Fleet)
    Re: Perl and Mysql (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 16 Jul 2000 13:50:01 GMT
From: tony_barratt@my-deja.com.bbs@openbazaar.net ()
Subject: parsing cronjob emails
Message-Id: <3bQOTO$UWS@openbazaar.net>

Hi,
I'd like to implement some perl code to react to incoming emails to root
and look for keywords like failed and generate an event if found.
Because there are a lot of cronjobs, on mostly Solaris boxes, that
invoke tasks like backup and send a email to root@localhost usually
using sendmail. It's a feature of cron to generate a email as a result
of output, from the cronjob, of either stdout and stderr. And there
usually is some.
So root's mailbox fills with emails that might say backup failed or
might say backup succeeded. emails that noone reads.
So i want to parse the email when it arrives and say turn the screen red
if a keyword is found. I guess I can find the relevant command to turn
the screen red on whatever GUI happends to be running.
But I'm not clear on how to react to emails. I expect there's a hard way
and a very hard way, but is there perhaps an easy way?

TIA

Tony




Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 16 Jul 2000 16:10:02 GMT
From: clintp@geeksalad.org.bbs@openbazaar.net (Clinton A. Pierce)
Subject: Re: parsing cronjob emails
Message-Id: <3bQSCT$X9o@openbazaar.net>

[Posted and mailed]

In article <8kse6e$ts4$1@nnrp1.deja.com>,
	tony_barratt@my-deja.com writes:
> Hi,
> I'd like to implement some perl code to react to incoming emails to root
> and look for keywords like failed and generate an event if found.
> [...]
> But I'm not clear on how to react to emails. I expect there's a hard way
> and a very hard way, but is there perhaps an easy way?

A combination of Perl and a package called procmail will do this job
quite nicely.  And easily.  Search the fine web for both.  :)


--
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours!
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man,
	you get rotten Miracles." --Miracle Max, The Princess Bride


------------------------------

Date: 16 Jul 2000 19:30:17 GMT
From: tony_barratt@my-deja.com.bbs@openbazaar.net ()
Subject: Re: parsing cronjob emails
Message-Id: <3bQXMe$THi@openbazaar.net>

I've compiled and installed procmail. It will as you suggest do the job
nicely. But it's a bit complex for what I want to do. It looks like I'd
need to use some procmail, some shellscripting some piping and some perl
coding. Which is OK but a bit challenging to maintain after I've moved
on.
Just perl would be good. A quick search of the Internet reveals that
perl POP3 and SMTP could replace fetchmail (for simple requirements).
I didn't find anything to replace procmail though.
Maybe it can't be done?

<wiser_now>
thanks for the input so far..

In article <nflc5.39424$fR2.361962@news1.rdc1.mi.home.com>,
  clintp@geeksalad.org (Clinton A. Pierce) wrote:
> [Posted and mailed]
>
> In article <8kse6e$ts4$1@nnrp1.deja.com>,
> 	tony_barratt@my-deja.com writes:
> > Hi,
> > I'd like to implement some perl code to react to incoming emails to
root
> > and look for keywords like failed and generate an event if found.
> > [...]
> > But I'm not clear on how to react to emails. I expect there's a hard
way
> > and a very hard way, but is there perhaps an easy way?
>
> A combination of Perl and a package called procmail will do this job
> quite nicely.  And easily.  Search the fine web for both.  :)
>
> --
>     Clinton A. Pierce              Teach Yourself Perl in 24 Hours!
>   clintp@geeksalad.org         for details see
http://www.geeksalad.org
> "If you rush a Miracle Man,
> 	you get rotten Miracles." --Miracle Max, The Princess Bride
>


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 16 Jul 2000 22:40:01 GMT
From: tony_barratt@my-deja.com.bbs@openbazaar.net ()
Subject: Re: parsing cronjob emails
Message-Id: <3bQcK2$UGK@openbazaar.net>

Ah Yes. this will do:
From www.cpan.org
SYNOPSIS
use Mail::Audit;
my $mail = Mail::Audit->new;
$mail->pipe("listgate p5p") if ($mail->from =~ /perl5-porters/);
$mail->accept("perl) if ($mail->from =~ /perl/);
$mail->reject("We do not accept spam") if looks_like_spam($mail);
$mail->ignore if $mail->subject =~ /boring/i;
In article <8kt21q$b5o$1@nnrp1.deja.com>,
  tony_barratt@my-deja.com wrote:
> I've compiled and installed procmail. It will as you suggest do the
job
> nicely. But it's a bit complex for what I want to do. It looks like
I'd
> need to use some procmail, some shellscripting some piping and some
perl
> coding. Which is OK but a bit challenging to maintain after I've moved
> on.
> Just perl would be good. A quick search of the Internet reveals that
> perl POP3 and SMTP could replace fetchmail (for simple requirements).
> I didn't find anything to replace procmail though.
> Maybe it can't be done?
>
> <wiser_now>
> thanks for the input so far..
>
> In article <nflc5.39424$fR2.361962@news1.rdc1.mi.home.com>,
>   clintp@geeksalad.org (Clinton A. Pierce) wrote:
> > [Posted and mailed]
> >
> > In article <8kse6e$ts4$1@nnrp1.deja.com>,
> > 	tony_barratt@my-deja.com writes:
> > > Hi,
> > > I'd like to implement some perl code to react to incoming emails
to
> root
> > > and look for keywords like failed and generate an event if found.
> > > [...]
> > > But I'm not clear on how to react to emails. I expect there's a
hard
> way
> > > and a very hard way, but is there perhaps an easy way?
> >
> > A combination of Perl and a package called procmail will do this job
> > quite nicely.  And easily.  Search the fine web for both.  :)
> >
> > --
> >     Clinton A. Pierce              Teach Yourself Perl in 24 Hours!
> >   clintp@geeksalad.org         for details see
> http://www.geeksalad.org
> > "If you rush a Miracle Man,
> > 	you get rotten Miracles." --Miracle Max, The Princess Bride
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 17 Jul 2000 19:50:04 GMT
From: lunatyc00@my-deja.com.bbs@openbazaar.net ()
Subject: pass change
Message-Id: <3bRNNR$Wrx@openbazaar.net>

I'm trying write a cgi script to allow users on a Unix system to change their
passes via the web.  I'm looking for some help with this.  Any takers?	Any
advice?


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 17 Jul 2000 20:50:03 GMT
From: jbroz@yperite.demon.co.uk.bbs@openbazaar.net (jb)
Subject: Re: pass change
Message-Id: <3bRP2S$X9c@openbazaar.net>

lunatyc00@my-deja.com wrote:
>
> I'm trying write a cgi script to allow users on a Unix system to change their
> passes via the web.  I'm looking for some help with this.  Any takers?  Any
> advice?

post in comp.infosystems.www.authoring.cgi (i think that's the name of
the group, check to be sure)


------------------------------

Date: 17 Jul 2000 20:50:03 GMT
From: bchodo@my-deja.com.bbs@openbazaar.net ()
Subject: Passing and using multidimensional array references
Message-Id: <3bRP2R$X5d@openbazaar.net>

I have a large array that I want to pass to a subroutine. I passed the
reference (\@array) to keep from having to pass the array, but now I'm
having trouble accessing individual elements in the file (i.e.)
I thought that I could do:
 
 
 
prog(\@array);

sub prog {
my @array = shift;
my $array;
# get element 2,5 of array
print "This is element 2,5:" . $$array[2][5];
return;

but it doesn't work. What am I doing wrong?

Thanks for your help


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 17 Jul 2000 21:50:02 GMT
From: lauren_smith13@hotmail.com.bbs@openbazaar.net (Lauren Smith)
Subject: Re: Passing and using multidimensional array references
Message-Id: <3bRQTQ$XHW@openbazaar.net>

<bchodo@my-deja.com> wrote in message news:8kvqt6$b5o$1@nnrp1.deja.com...
> I have a large array that I want to pass to a subroutine. I passed the
> reference (\@array) to keep from having to pass the array, but now I'm
> having trouble accessing individual elements in the file (i.e.)
> I thought that I could do:
> .
> prog(\@array);
>
> sub prog {
> my @array = shift;

my $arrayref = shift;

> my $array;

Unnecessary.

> # get element 2,5 of array
> print "This is element 2,5:" . $$array[2][5];
> return;

You aren't getting an array when you shift @_.  Avoid using the same names
for different variables:  @array != $array.

Lauren


------------------------------

Date: 17 Jul 2000 22:10:02 GMT
From: sumus@aut.dk.bbs@openbazaar.net (Jakob Schmidt)
Subject: Re: Passing and using multidimensional array references
Message-Id: <3bRR6Q$Tvq@openbazaar.net>

bchodo@my-deja.com writes:

> sub prog {
> my @array = shift;

this merely puts the array ref you passed as parameter into $array[ 0 ].

> my $array;

I'm not sure what you expected this to do?

> # get element 2,5 of array
> print "This is element 2,5:" . $$array[2][5];

nonono - use the dereference operator -> as in:

$arrayref->[ 2 ][ 5 ];

Cleanup:

sub prog {
    my $arrayref = shift;
    print "This is element 2,5: $arrayref->[ 2 ][ 5 ]\n";
}

--
Jakob


------------------------------

Date: 17 Jul 2000 22:30:03 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Passing and using multidimensional array references
Message-Id: <3bRRVR$TPY@openbazaar.net>

bchodo@my-deja.com wrote ..
>I have a large array that I want to pass to a subroutine. I passed the
>reference (\@array) to keep from having to pass the array, but now I'm
>having trouble accessing individual elements in the file (i.e.)
>I thought that I could do:
>.
>.
>.
>prog(\@array);

here you pass a reference to an array .. a scalar

>sub prog {
>my @array = shift;

here you assign a scalar to an array which will have the effect of
setting the first element of your array to that scalar .. ie. the array
reference from outside will be in $array[0]

you need to realise that an array reference is a scalar .. it is store
in a scalar variable .. take a look at

  perldoc perlref

--
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: 17 Jul 2000 10:40:02 GMT
From: dfleet@avaterra.com.bbs@openbazaar.net (David Fleet)
Subject: Perl and Mysql
Message-Id: <3bR982$VKH@openbazaar.net>

I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?

Han.


------------------------------

Date: 17 Jul 2000 11:10:01 GMT
From: dfleet@avaterra.com.bbs@openbazaar.net (David Fleet)
Subject: Perl and Mysql
Message-Id: <3bR9jP$VOC@openbazaar.net>

I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?

Han.


------------------------------

Date: 17 Jul 2000 11:10:01 GMT
From: dfleet@avaterra.com.bbs@openbazaar.net (David Fleet)
Subject: Perl and Mysql
Message-Id: <3bR9jQ$Vvq@openbazaar.net>

I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?

Han.


------------------------------

Date: 17 Jul 2000 11:10:02 GMT
From: dfleet@avaterra.com.bbs@openbazaar.net (David Fleet)
Subject: Perl and Mysql
Message-Id: <3bR9jR$Vzt@openbazaar.net>

I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?

Han.


------------------------------

Date: 17 Jul 2000 11:10:02 GMT
From: bernard.el-hagin@lido-tech.net.bbs@openbazaar.net (Bernard El-Hagin)
Subject: Re: Perl and Mysql
Message-Id: <3bR9jT$W5n@openbazaar.net>

On Mon, 17 Jul 2000 11:48:44 +0100, David Fleet <dfleet@avaterra.com> wrote:
>I am having serious problems trying to get my Perl script to connect to my
>Mysql database.

You are having serious trouble with posting the same post 4 times.

Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#


------------------------------

Date: 17 Jul 2000 11:50:01 GMT
From: thunderbear@bigfoot.com.bbs@openbazaar.net (Thorbjørn Ravn Andersen)
Subject: Re: Perl and Mysql
Message-Id: <3bRAlP$WC3@openbazaar.net>

David Fleet wrote:
>
> I am having serious problems trying to get my Perl script to connect to my
> Mysql database.

Can have many reasons.  What errors do you see?

--
  Thorbjørn Ravn Andersen         "...plus...Tubular Bells!"
  http://bigfoot.com/~thunderbear


------------------------------

Date: 17 Jul 2000 13:40:01 GMT
From: dfleet@avaterra.com.bbs@openbazaar.net (David Fleet)
Subject: Re: Perl and Mysql
Message-Id: <3bRDf3$Tne@openbazaar.net>

Sorry about multiple postings, had a network/mail problem.
Thankyou for replying.
 Code :--
----------------------------------------------------------------
#!/usr/bin/perl -w



print "Content-type: text/html\n\n";


use DBI;

@fdf= DBI->available_drivers;
$fdf=@fdf;

for($a=0;$a<$fdf;$a++){
    print "<BR>$a @fdf[$a]";
   }


$path = "DBI:mysql:test2:localhost";
$user = "MYUSERNAME";
$pswd = "PASSWORD";

$dbh = DBI->connect($path,$user,$pswd);

$dbq = $dbh->prepare("select * from books");
-----------------------------------------------------------------
In my 'error_log' file, it says :-
"Can't connect to local MySQL server through socket /tmp/mysql.sock"

I can use mysql from the Linux command line and do everything it's meant to
do.
No problem with that.
Just not with a Perl script.

Different sources say,use "use Mysql", whereas others say "use DBI";

What can I do??

Han.


"Thorbjørn Ravn Andersen" <thunderbear@bigfoot.com> wrote in message
news:3972F455.F279F7E2@bigfoot.com...
> David Fleet wrote:
> >
> > I am having serious problems trying to get my Perl script to connect to
my
> > Mysql database.
>
> Can have many reasons.  What errors do you see?
>
> --
>   Thorbjørn Ravn Andersen         "...plus...Tubular Bells!"
>   http://bigfoot.com/~thunderbear


------------------------------

Date: 17 Jul 2000 22:50:03 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: Perl and Mysql
Message-Id: <3bRS8S$VG6@openbazaar.net>

David Fleet (dfleet@avaterra.com) wrote on MMDXII September MCMXCIII in
<URL:news:3972e268_1@nnrp1.news.uk.psi.net>:
## I am having serious problems trying to get my Perl script to connect to my
## Mysql database.
## Has anyone had problems trying to get Perl to access their mysql database?

Yes.

## If so, what did you have to do to correct it?

I fixed the typo in the password.



HTH. HAND.



Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
           print+Just (), another (), Perl (), Hacker ();'


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3722
**************************************


home help back first fref pref prev next nref lref last post