Forum Moderators: coopster & phranque

Message Too Old, No Replies

perl and sendmail

perl and sendmail

         

StopSpam

8:52 am on May 13, 2003 (gmt 0)

10+ Year Member



is there a code or trick i can add to a perl script
t make sure sendmailcanonly send one email in a second ...

i made a script thats mails me ip and useragent from each 301 error
sometimes i get 5 to 20 emails send by same user ip all in one second ...

is it posible to insert some block so sendmail can only send one email in a second?

is this posible can some one show me how

jatar_k

4:23 pm on May 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



<bump>so it doesn't get lost

BCMG_Scott

7:11 pm on May 13, 2003 (gmt 0)

10+ Year Member



yep, sleep

[perldoc.com...]

Scott Geiger

StopSpam

8:38 pm on May 13, 2003 (gmt 0)

10+ Year Member



thanks for reply ...

if i understand well these are modules?

i go read that url thx ...

i dont want to use a module ...
i'm looking for few lines code i can add to my current script to avoid over use of sendmail

BCMG_Scott

8:45 pm on May 13, 2003 (gmt 0)

10+ Year Member



sleep is not a module, they do reference some modules you can use if you need a finer grain than a second interval. The sleep function is a basic part of perl (no extra install needed).

Scott

StopSpam

8:47 pm on May 13, 2003 (gmt 0)

10+ Year Member



is that corect all ihave to add to the script is this code
at the end of were sendmail sends the email?

print MAIL "--------------------------\n";
close (MAIL);
sleep(EXPR)
sleep EXPR
sleep

then script will sleep for 1 a 2 seconds?

is this corect?

BCMG_Scott

9:06 pm on May 13, 2003 (gmt 0)

10+ Year Member



all you need is just one sleep, so:

print MAIL "--------------------------\n";
close (MAIL);
sleep 1;

will do it. I assume the print, close and sleep are within a loop (either for or while)

Scott

StopSpam

9:09 pm on May 13, 2003 (gmt 0)

10+ Year Member



ok thanks i go try it ...

if it works i go scream loud

god i love perl hehehehe

StopSpam

10:27 am on May 15, 2003 (gmt 0)

10+ Year Member



close (MAIL);
sleep 3;

works perfect thx

BCMG_Scott

6:49 pm on May 15, 2003 (gmt 0)

10+ Year Member



Great! :)

Scott

StopSpam

12:56 am on May 24, 2003 (gmt 0)

10+ Year Member



Im back ...

i used

print MAIL "--------------------------\n";
close (MAIL);
sleep 5;

the script is sleeping for 5 seconds ...
but the robot can still browser the site
and errors are still writen to log file ....

Is it posible to make the whole server sleep for few seconds? so the browser gives time out error or somthing or server not ecsist?

BCMG_Scott

1:40 pm on May 28, 2003 (gmt 0)

10+ Year Member



I think I see what you are trying/wanting to do now. Correct me if I am wrong here: You are being spidered and you want to kick off an email to you when you are spidered and then stop the spider, right?

There are a few options you can do here:

1. you can just place the user agent in the robots.txt file and hope that it follows the robot rules. That will deny it from whatever paths you set.

2. you could use mod_rewrite to execute a perl script on 301 errors, log the UA to the robots.txt file and send an email. However, if it does not use robots.txt it won't work

Other options may be using hosts.allow/deny (but only if Apache is configured to look at those - it's not by default). Or add a DROP target for that IP to iptables (complex and needs sysadmin access if not root).

Probably option 2 is the best bet, but it does require some coding and will require some work with mod re_write.

Scott