I don't have to run it from a tmp directory. In fact I just created a directory named tmp to work in. I was trying to do this from the root directory also. Here is te script
#!/usr/bin/perl
#
# This code is distributed under the terms of the GPL
#
# (c) 2008 marco.s -
http://www.urlfiter.net
#
# $Id: mvphosts2blacklist,v 1.0 2008/08/10 00:00:00 marco.s Exp $
#
use strict;
use Getopt::Std;
my $swroot="/var/ipcop";
my $dbdir="$swroot/urlfilter/blacklists";
my $executable=substr($0,rindex($0,"/")+1,length($0));
getopts('');
unless (-T $ARGV[0]) { &HELP_MESSAGE; exit; }
unless (-d "$dbdir/mvphosts") { mkdir "$dbdir/mvphosts"; }
open (INFILE,$ARGV[0]);
open (OUTFILE,">$dbdir/mvphosts/domains");
while (<INFILE>)
{
s/127\.0\.0\.1\s+//g; s/#.*//g; s/^\s+//g; s/\s+$//g;
if ($_) { print OUTFILE "$_\n"; }
}
close INFILE;
close OUTFILE;
open (CONFIG,">/tmp/mvphosts.conf");
print CONFIG <<END
dbhome $dbdir
dest mvphosts {
domainlist mvphosts/domains
}
acl {
default { pass none }
}
END
;
close CONFIG;
if (-e "$dbdir/mvphosts/domains") { system ("/usr/sbin/squidGuard -d -c /tmp/mvphosts.conf -C $dbdir/mvphosts/domains"); }
unlink ("/tmp/mvphosts.conf");
system ("chown -R nobody:nobody $dbdir/mvphosts");
if (-e "$dbdir/mvphosts/domains.db") { system ("chmod 666 $dbdir/mvphosts/domains.db"); }
# -------------------------------------------------------------------
sub VERSION_MESSAGE
{
$Getopt::Std::STANDARD_HELP_VERSION=1;
print <<EOM
$executable (URLfilter coreutils) 1.00
Copyright (c) 2008 marco.s -
http://www.urlfilter.net
EOM
;
}
# -------------------------------------------------------------------
sub HELP_MESSAGE
{
print <<EOM
Usage: $executable FILE
Converts FILE into a blacklist named mvphosts
FILE must be a hostfile from mvps.org
(
http://www.mvps.org/winhelp2002/hosts.htm)
--help display this help
--version output version information
EOM
;
}
# -------------------------------------------------------------------