FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 06-23-2008, 05:52 PM
Stephen Harris
 
Default Awk help

On Mon, Jun 23, 2008 at 11:25:45AM -0600, Joseph L. Casale wrote:
> I have csvde dump from active directory I process on my postfix mta.
> It takes output like this:
>
> "CN=Curtis xxx,OU=Domain Users,OU=xxx xxx,DC=xxx-xxx,DC=local",X400:c=US;a= ;p=xxx xxx xxx;o=Exchange;s=xxx;g=xxx;;SMTP:Cxxx@xxx-xxx.com
>
> and should return a relay_recipient map in the form of:
> Cxxx@xxx-xxx.com OK
>
> The command I am using is:
> cat $1 | tr -d " | tr ,
| tr ;
| awk -F: '/(SMTP|smtp):/ {printf("%s OK
",$2)}'

Use sed instead:
sed -n 's/^.*;;SMTP.*)$/1 OK/p' < $1

> Everything up to the awk is working, it drops the smtp: but its putting OK's all over the darn place.
> Anyone familiar enough with awk and printf that can suggest why this happens?

It works OK on the test line you provided; my guess is your datafile
has other lines that match "SMTP" in other fields of the source.

--

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 06-23-2008, 06:30 PM
"Joseph L. Casale"
 
Default Awk help

>It works OK on the test line you provided; my guess is your datafile
>has other lines that match "SMTP" in other fields of the source.

Yeah when I echo'ed a single email into it everything was fine, but the file wasn't. I looked at
it in vi and saw all the dos carriage returns so added a tr -d '
' before the awk.

I will check out the sed statement, thanks!
jlc
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 06-23-2008, 09:22 PM
"Spiro Harvey, Knossos Networks Ltd"
 
Default Awk help

I have csvde dump from active directory I process on my postfix mta.
It takes output like this:
"CN=Curtis xxx,OU=Domain Users,OU=xxx xxx,DC=xxx-xxx,DC=local",X400:c=US;a= ;p=xxx xxx xxx;o=Exchange;s=xxx;g=xxx;;SMTP:Cxxx@xxx-xxx.com
and should return a relay_recipient map in the form of:
Cxxx@xxx-xxx.com OK
Everything up to the awk is working, it drops the smtp: but its putting OK's all over the darn place.
Anyone familiar enough with awk and printf that can suggest why this happens?


you can simplify that line down to:

awk 'BEGIN { FS=":" } /(smtp|SMTP)/ { printf "%-30sOK
", $NF }' $1

the -30 will make sure that everything aligns, because with just a tab
to separate the email addresses, you'll end up with a wonky OK column.
-30 pads out the first column to 30 characters.


also, I recommend changing the /(smtp|SMTP)/ to just /SMTP/ because if a
program is producing output like this from AD or LDAP, then the SMTP
will always be caps. You risk matching other lines in the log file that
don't match this format.


basically, this script separates a line by colons ':' and prints the
last field if the line fed to it contains 'smtp' or 'SMTP'. The $NF is
Number of Fields, so effectively prints the last field.





--
Spiro Harvey Knossos Networks Ltd
021-295-1923 www.knossos.net.nz

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 06-23-2008, 09:38 PM
"Joseph L. Casale"
 
Default Awk help

>you can simplify that line down to:
>
>awk 'BEGIN { FS=":" } /(smtp|SMTP)/ { printf "%-30sOK
", $NF }' $1
>
>the -30 will make sure that everything aligns, because with just a tab
>to separate the email addresses, you'll end up with a wonky OK column.
>-30 pads out the first column to 30 characters.
>
>also, I recommend changing the /(smtp|SMTP)/ to just /SMTP/ because if a
>program is producing output like this from AD or LDAP, then the SMTP
>will always be caps. You risk matching other lines in the log file that
>don't match this format.
>
>basically, this script separates a line by colons ':' and prints the
>last field if the line fed to it contains 'smtp' or 'SMTP'. The $NF is
>Number of Fields, so effectively prints the last field.


Well, the theory behind the case insensitivity is for users with more that one email address.
The primary is always caps, but secondary's are lower case.

Thanks for the pointer!
jlc
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 08:09 PM
ann kok
 
Default awk help

Hi all

Anyone can help to let me know how to

ls -1 | lsattr


ls -al /folder | awk '{ print $2}' | lsattr

Thank you


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 09:07 PM
Christopher Chan
 
Default awk help

On Thursday, December 02, 2010 05:09 AM, ann kok wrote:
> Hi all
>
> Anyone can help to let me know how to
>
> ls -1 | lsattr

lsattr `ls -1`

>
>
> ls -al /folder | awk '{ print $2}' | lsattr
>


for i in `ls -al /folder | awk '{ print $8}'`; do lsattr /folder/$i; done
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 10:44 PM
Ross Walker
 
Default awk help

On Dec 1, 2010, at 5:07 PM, Christopher Chan <christopher.chan@bradbury.edu.hk> wrote:

> On Thursday, December 02, 2010 05:09 AM, ann kok wrote:
>> Hi all
>>
>> Anyone can help to let me know how to
>>
>> ls -1 | lsattr
>
> lsattr `ls -1`
>
>>
>>
>> ls -al /folder | awk '{ print $2}' | lsattr
>>
>
>
> for i in `ls -al /folder | awk '{ print $8}'`; do lsattr /folder/$i; done

You can probably do that last one as a pipe to xargs instead of a shell loop.

-Ross

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 10:57 PM
Les Mikesell
 
Default awk help

On 12/1/2010 5:44 PM, Ross Walker wrote:
> On Dec 1, 2010, at 5:07 PM, Christopher Chan<christopher.chan@bradbury.edu.hk> wrote:
>
>> On Thursday, December 02, 2010 05:09 AM, ann kok wrote:
>>> Hi all
>>>
>>> Anyone can help to let me know how to
>>>
>>> ls -1 | lsattr
>>
>> lsattr `ls -1`
>>
>>>
>>>
>>> ls -al /folder | awk '{ print $2}' | lsattr
>>>
>>
>>
>> for i in `ls -al /folder | awk '{ print $8}'`; do lsattr /folder/$i; done
>
> You can probably do that last one as a pipe to xargs instead of a shell loop.

I'm missing something here. Why does lsattr need help from ls?

--
Les Mikesell
lesmikesell@gmail.com


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 11:19 PM
Christopher Chan
 
Default awk help

On Thursday, December 02, 2010 07:57 AM, Les Mikesell wrote:
> On 12/1/2010 5:44 PM, Ross Walker wrote:
>> On Dec 1, 2010, at 5:07 PM, Christopher Chan<christopher.chan@bradbury.edu.hk> wrote:
>>
>>> On Thursday, December 02, 2010 05:09 AM, ann kok wrote:
>>>> Hi all
>>>>
>>>> Anyone can help to let me know how to
>>>>
>>>> ls -1 | lsattr
>>>
>>> lsattr `ls -1`
>>>
>>>>
>>>>
>>>> ls -al /folder | awk '{ print $2}' | lsattr
>>>>
>>>
>>>
>>> for i in `ls -al /folder | awk '{ print $8}'`; do lsattr /folder/$i; done
>>
>> You can probably do that last one as a pipe to xargs instead of a shell loop.
>
> I'm missing something here. Why does lsattr need help from ls?
>

It does not. I don't know why the OP is even trying to do it this way.
Just thought I'd demonstrate some bash stuff. :-p
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-02-2010, 01:37 AM
Stephen Harris
 
Default awk help

On Thu, Dec 02, 2010 at 08:19:51AM +0800, Christopher Chan wrote:
> It does not. I don't know why the OP is even trying to do it this way.

My guess: school work.

--

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 12:08 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org