All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Knoell <jens@surefoot.com>
To: Fernando <ferosspublic@comcast.net>
Cc: linux-admin@vger.kernel.org
Subject: Re: Need Help with making a bash script
Date: Fri, 28 May 2004 16:40:32 -0600	[thread overview]
Message-ID: <40B7BFE0.7070503@surefoot.com> (raw)
In-Reply-To: <c98bdh$7s8$1@sea.gmane.org>

Hi Fernando

answers inline.

Fernando wrote:
> I have two problems.
> 
> 
> 1. I'm making a script to add IP's to my blacklist...
> 
> I need to add three <tabs>, the word 'REJECT' and a #DDMMYYYY that it's 
> being done to a text file that has the IP's in it... ie this is the 
> original list;
> 
> 80.25.148.216
> 80.43.197.197
> 
> needs to end up like this...
> 
> 80.25.148.216            REJECT    #28052004
> 80.43.197.197            REJECT    #28052004

I just happen to have almost exactly such a script running here. The 
relevant part is this one here, modified to your needs. It requires that 
you set SOURCEFILE to whatever file you use. Same for DESTFILE. I didn't 
put any secure checks for either source or dest in there, just FYI.

rm $DESTFILE
cat $SOURCEFILE | while read TCPREMOTEIP
do
   echo "$TCPREMOTEIP<insert TABs here>REJECT #`date +%Y%m%d`" >> $DESTFILE
done

The same thing can probably also be done faster with sed.

> 2. The second is a little bit more complicated.
> 
> My server is having trouble deleting virus emails, I want to help it 
> along with a little cron job that will clear out virus emails every 10 
> minutes or so. I get the list of infected emails from the maillog but in 
> the maillog only the email ID is displayed. In the actual queue there 
> are two files per 1 email ID.
> 
> ie... this is what the log spits out as emails that are infected that I 
> want to delete...
> 
> foo1
> foo2
> foo3
> 
> but in the queue there are two files per email, a qffoo and a dffoo so 
> in the queue the previous emails would actually be...
> 
> dffoo1
> qffoo1
> dffoo2
> qffoo2
> dffoo3
> qffoo3
> 
> So, is it possible to run rm with a wildcard to compensate for the df qf 
> letters and still feed it the list of email ID's which make up the last 
> part of the df qf files?

Yes, simply run it with wildcards like this: rm ??foo1

Hope this helps

Jen

  reply	other threads:[~2004-05-28 22:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-28 21:36 Need Help with making a bash script Fernando
2004-05-28 22:40 ` Jens Knoell [this message]
2004-05-28 22:43 ` Herta Van den Eynde
2004-05-29  5:04   ` Fernando
2004-05-28 23:52 ` chuck gelm
2004-05-29  0:05 ` chuck gelm
2004-05-29  0:59 ` A. R. Vener
2004-05-29 20:00 ` Russell Evans
2004-06-01 13:03   ` Fernando

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40B7BFE0.7070503@surefoot.com \
    --to=jens@surefoot.com \
    --cc=ferosspublic@comcast.net \
    --cc=linux-admin@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.