Re: [eug-lug]stream limits? or algorithm help
Cory Petkovsek wrote: On Fri, Mar 19, 2004 at 09:15:02AM -0800, Bob Miller wrote: What is the limit on streams? I still would like to know the max stream count. Is it file descriptors? If so what is that, 65535? So I could use 'echo blah 65535' (didn't seem to work)? bash$ ulimit -a | grep open open files(-n) 1024 tcsh% limit | grep desc descriptors 1024 -- Bob Miller Kbob kbobsoft software consulting http://kbobsoft.com [EMAIL PROTECTED] ___ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug
Re: [eug-lug]stream limits? or algorithm help
Jacob Meuser wrote: #!/bin/sh TEMPDIR=`mktemp -d` while read addr junk do dom=`echo $addr | cut -d '@' -f 2` echo $addr OK $TEMPDIR/$dom done MYDIR=`pwd` cd $TEMPDIR for i in * do sort $i echo $i REJECT done cd $MYDIR rm -rf $TEMPDIR exit 0 Very good! (-: May I suggest one small improvement? Set up a trap handler to delete the temp dir. That way it'll be cleaned up even if the script is interrupted (e.g., you pipe the output through less and quit before reaching the end). #!/bin/sh TEMPDIR=`mktemp -d` trap 'rm -rf $TEMPDIR' EXIT # ... rest of script ... -- Bob Miller Kbob kbobsoft software consulting http://kbobsoft.com [EMAIL PROTECTED] ___ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug
Re: [eug-lug]stream limits? or algorithm help
On Sun, Mar 21, 2004 at 12:07:29AM -0800, Bob Miller wrote: Jacob Meuser wrote: #!/bin/sh TEMPDIR=`mktemp -d` while read addr junk do dom=`echo $addr | cut -d '@' -f 2` echo $addr OK $TEMPDIR/$dom done MYDIR=`pwd` cd $TEMPDIR for i in * do sort $i echo $i REJECT done cd $MYDIR rm -rf $TEMPDIR exit 0 Very good! (-: Thanks :) May I suggest one small improvement? Set up a trap handler to delete the temp dir. That way it'll be cleaned up even if the script is interrupted (e.g., you pipe the output through less and quit before reaching the end). #!/bin/sh TEMPDIR=`mktemp -d` trap 'rm -rf $TEMPDIR' EXIT # ... rest of script ... Thanks for the pointer. I was actually just looking at such trap handlers in the XFree86 build scripts. Also, this part: MYDIR=`pwd` cd $TEMPDIR for i in * do sort $i echo $i REJECT done cd $MYDIR rm -rf $TEMPDIR could be replaced with: for i in $TEMPDIR/* do sort $i echo `basename $i` REJECT done -- [EMAIL PROTECTED] ___ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug
Re: [eug-lug]stream limits? or algorithm help
On Fri, Mar 19, 2004 at 09:15:02AM -0800, Bob Miller wrote: What is the limit on streams? I still would like to know the max stream count. Is it file descriptors? If so what is that, 65535? So I could use 'echo blah 65535' (didn't seem to work)? This seems like a task that is simple in Python or Perl, but less simple as a shell script. Assuming you have the first file above as stdin, either of the attached scripts produces the second file. Thanks for the scripts. Of course a hash of arrays is the _obvious_ solution! Cory -- Cory Petkovsek Adapting Information Adaptable IT ConsultingTechnology to Your (858) 705-1655 Business [EMAIL PROTECTED] www.AdaptableIT.com ___ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug
Re: [eug-lug]stream limits? or algorithm help
On Fri, Mar 19, 2004 at 09:15:02AM -0800, Bob Miller wrote: This seems like a task that is simple in Python or Perl, but less simple as a shell script. #!/usr/bin/env python import fileinput users = {} for line in fileinput.input(): addr = line.strip() domain = addr.split('@')[-1] users.setdefault(domain, []).append(addr) domains = users.keys() domains.sort()# Sort domains so successive # versions of this file can be # diff'ed. for domain in domains: u = users[domain] u.sort()# Sort users for the same reason. for user in u: print user, 'OK' print domain, 'REJECT' #!/bin/sh TEMPDIR=`mktemp -d` while read addr junk do dom=`echo $addr | cut -d '@' -f 2` echo $addr OK $TEMPDIR/$dom done MYDIR=`pwd` cd $TEMPDIR for i in * do sort $i echo $i REJECT done cd $MYDIR rm -rf $TEMPDIR exit 0 -- [EMAIL PROTECTED] ___ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug
Re: [eug-lug]stream limits? or algorithm help
Cory Petkovsek wrote: What is the limit on streams? Here's what I'm intending to do and perhaps someone has a better solution: I have a list of email addresses for a virtual email host: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] I want to group by domain, append an ' OK' and insert a '$domain REJECT' after each domain block. The output should look like this: [EMAIL PROTECTED] OK [EMAIL PROTECTED] OK [EMAIL PROTECTED] OK happy.com REJECT [EMAIL PROTECTED] OK blah.com REJECT [EMAIL PROTECTED] OK test.org REJECT This seems like a task that is simple in Python or Perl, but less simple as a shell script. Assuming you have the first file above as stdin, either of the attached scripts produces the second file. -- Bob Miller Kbob kbobsoft software consulting http://kbobsoft.com [EMAIL PROTECTED] #!/usr/bin/env python import fileinput users = {} for line in fileinput.input(): addr = line.strip() domain = addr.split('@')[-1] users.setdefault(domain, []).append(addr) domains = users.keys() domains.sort() # Sort domains so successive # versions of this file can be # diff'ed. for domain in domains: u = users[domain] u.sort()# Sort users for the same reason. for user in u: print user, 'OK' print domain, 'REJECT' cory.pl Description: Perl program ___ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug
[eug-lug]stream limits? or algorithm help
What is the limit on streams? Here's what I'm intending to do and perhaps someone has a better solution: I have a list of email addresses for a virtual email host: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] I want to group by domain, append an ' OK' and insert a '$domain REJECT' after each domain block. The output should look like this: [EMAIL PROTECTED] OK [EMAIL PROTECTED] OK [EMAIL PROTECTED] OK happy.com REJECT [EMAIL PROTECTED] OK blah.com REJECT [EMAIL PROTECTED] OK test.org REJECT I want to process the input once for scalability. Right now I have a small perl script that opens up 1 through # of domains as streams (ie 1, 2, 3). Then I intend to capture these streams in order. The streams are all stored in a hash. However something tells me this is only an exercise in stream fun and not the ideal approach. Pseudo code, Perl or shell solutions are welcome. Here's a naive way I could do this with bash, however it calls ldapdump repeatedly. ldapdump is a perl script that dumps all email addresses from an ldap server. ( for i in `cat destination_domains` ; do ldapdump | egrep $i | sed -e 's/$/ OK/'; echo $i REJECT ; done ) valid_local_senders Finally, here's why: Postfix has the capability to reject email for addresses that don't exist on it's local domains. However it does not have the native configured ability to reject email From: non-existent addresses on it's local domains. Well I figured out how to configure it. Now for a specific set of domains that the local mail server is responsible for, email must be either to or from valid users. Cory -- Cory Petkovsek Adapting Information Adaptable IT ConsultingTechnology to Your (858) 705-1655 Business [EMAIL PROTECTED] www.AdaptableIT.com ___ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug