in reply to Re^2: script outputs nothing/nada
in thread script outputs nothing/nada

open (BADIPS), "< $workdir/bad_ips" or die "Couldn't open file: $!";

If that's the code you're really using (it's different to your OP), try adding use warnings; after use strict;. That usage of open does something you really don't want (hint: it isn't trying to open bad_ips).

Try:

open BADIPS, "<", "$workdir/bad_ips" or die "Couldn't open file: $!";

instead.

You should also check the contents of bad_ips. It could be full of newlines.

Replies are listed 'Best First'.
Re^4: script outputs nothing/nada
by bluethundr (Pilgrim) on Jun 06, 2010 at 23:42 UTC
    Hello, I have tried stripping the newlines out of the bad_ips text file with the following command.

    grep -ri s/"\n"// ~/txt/bad_ips


    And made the following changes to the code.
    #!/usr/bin/perl # use strict; use warnings; # # my $workdir = "$ENV{HOME}/txt"; open BADIPS, "<", "$workdir/bad_ips" or die "Couldn't open file: $!"; my $i = 1; while (my $line = <BADIPS>) { chomp $line; print "add ns simpleacl bp-search-spammer$i DENY -srcIP $line -T +TL 43200\n"; $i++; } close BADIPS;<br><br>
    That worked BEAUTIFULLY! Thank you!!!