You are not logged in.

#1 2013-07-30 21:18:23

vfbsilva
Member
From: Brazil
Registered: 2010-04-08
Posts: 103

[Solved]Generating Ldiffs with Help from AWK (can't parse input file)

Folks I'm trying to generate an ldiff file based on an awk input:
I have this:

awk -v uid=999905284 '
{
print "dn: uid="$0",ou=aaa,ou=bbb,dc=br\n
uid: "$0"\n
givenName: MailList\n
sn: "$0"\n
cn: "$0"\n
homeDirectory: /home/false\n
loginShell: /bin/false\n
mail: "$0"@grupos.a.br\n
description: "$0"\n
admlista: admin@a.br\n
admlista: a@a\n
listPass: pass\n
objectClass: posixAccount\n
objectClass: inetOrgPerson\n
objectClass: shadowAccount\n
objectClass: phpgwAccount\n
objectClass: top\n
objectClass: person\n
objectClass: organizationalPerson\n
objectClass: mailman\n
phpgwAccountType: l\n
phpgwAccountStatus: A\n
uidNumber: "uid++"\n
gidNumber: 0\n
deliveryMode: forwardOnly\n
accountStatus: active\n
defaultMemberModeration: 1\n"
}' listas_minusculo_ok

The input file called: listas_minusculo_ok holds the following info:

list-a
list-b
...
list-n

Expected output is and ldiff where uid is incremented and each "list-n" has an ldiff entry, what am I doing so wrong? I keep having unfinished string errors hmm

Last edited by vfbsilva (2013-07-31 05:14:22)

Offline

#2 2013-07-31 05:13:59

vfbsilva
Member
From: Brazil
Registered: 2010-04-08
Posts: 103

Re: [Solved]Generating Ldiffs with Help from AWK (can't parse input file)

So here I answer my own question:
awk doesn't allow you to split quoted strings over two lines, unless you mark each line as a continuation by putting a \ at the end. Since you I`m already including \n in the output explicitly, just fixed things up by putting the continuation markers everywhere a quoted string is split:

awk -v uid=999905284 '
{
print "dn: uid="$0",ou=aaa,ou=bbb,dc=br\n\
uid: "$0"\n\
sn: "$0"\n\
cn: "$0"\n\
mail: "$0"@grupos.a.br\n\
description: "$0"\n\
phpgwAccountType: l\n\
phpgwAccountStatus: A\n\
uidNumber: "uid++"\n\
gidNumber: 0\n\
deliveryMode: forwardOnly\n\
accountStatus: active\n\
defaultMemberModeration: 1\n"
}' list

Last edited by vfbsilva (2013-07-31 14:09:36)

Offline

Board footer

Powered by FluxBB