A Pluckeye Forum

A place for Pluckeye users to chew the cud.

You are not logged in.


This is the old forum. The new forum is at https://discourse.pluckeye.net/ .

#1 2021-02-04 17:32:20

Registered: 2020-01-30
Posts: 10

Three possibly helpful scripts

I wrote 2 Perl Scripts that I thought. They are very simple and not the best written but they have been helpful to me and I figured it's good to share. All of these files I release into the public domain with no liability expressed or implied etc to the extent legal by law. To use, just copy the code into a file with the specified filename, put into one folder, and run as per the comments. Currently I've only used it on Ubuntu.


#Allows the specified site, except within 2 time frames
#usage: perl addsometimes_public.pl SITENAME
my $sitename = $ARGV[0];
my $firstblocked = "0000-1300";
my $secondblocked = "1500-2359";

my $allow_cmd = "pluck add \"allow $sitename\"";

my $first_block = "pluck add \"sometimes $firstblocked block $sitename\"";
my $second_block = "pluck add \"sometimes $secondblocked block $sitename\"";

system $allow_cmd;
system $first_block;
system $second_block;


#calls addsometimes.pl on a text file of URLs, 1 per line
#usage: perl somefromfile.pl FILENAME 

my $fp = $ARGV[0];

my $slurp = `cat $fp`;

my @s   = split (/\n/ ,$slurp);

foreach $i (@s){
	system ("perl addsometimes.pl $i");


#removes any onetime rules
#usage perl remove_onetimers.pl

my $settings = `pluck export`;

open (my $sfh, '<', \$settings) or die "canot open sfh!\n";

while (my $line = <$sfh>){
	chomp $line;
	if ($line =~ /\d{14}\-\d{14}/ and $line !~ /^#/ ) {
		system "pluck - $line";

Example input file for somefromfile.pl


And also I just put into my .bashrc:

 alias somepluck='perl ~/filter/addsometimes.pl'

So you could do "somepluck dilbert.com" for example (whatever your home directory is)

Hope it's useful to someone!


#2 2021-02-06 06:17:23

Registered: 2017-01-10
Posts: 525

Re: Three possibly helpful scripts

Thanks for sharing!

A comment or two:

1. "sometimes" is deprecated; change it to "when" for modern pluckeye

2. FYI, you can combine time frames like so:

pluck + when '1-2&3-4' block example.com

You can either quote the '&' as above, or escape it with a backslash.  And in Pluck 1.0, you can use a comma (,) instead of ampersand (&) to avoid the need to quote.


Board footer

Powered by FluxBB