Eric MSP Veith ha scritto:
> Hello,
> 
> I've spent some time trying to figure out what that script ought to do, but I 
> failed. I keep assuming that it should *set* the domain name, because of 
> `[ -n ${NISDOMAIN} ] && /bin/domainname "${NISDOMAIN}"ยด, but without further 
> knowledge of the AWK piece we cannot tell.
> 
> ...
> 

Hello all,
I'm a "normal" InitNG user (I mean, I'm not developing it), but I follow
this ML. I've tried to figure out what that AWK command does. I actually
have initng 0.6.7(-1) on my Debian, and the line in
/etc/initng/system/domainname.i was:

/usr/bin/awk '$1=="domain"&&ARGV[2]!=""{$2=ARGV[2]}{print}'
/etc/resolv.conf "${DNSDOMAIN}"

This line does the following (in pseudo code):

if (($1 == "domain") && (ARGV[2] != "")) {
    $2 = ARGV[2];
    print;
}

Now, what are those $1 and $2? They are the words awk strips out from
/etc/resolv.conf. My resolv.conf is:

nameserver 208.67.222.222
nameserver 208.67.220.220

Now, awk takes as default "word separator" the space character.
Therefore, in my resolv.conf, $1 would be "nameserver" and $2 would be
the ip address, for each single line.

That awk script, definitely, does the following: checks if the line
begins with "domain", if it does, it checks that $DNSDOMAIN is not empty
 (ARGV[2]!=""). If it is not, it sets $2 to that $DNSDOMAIN, and prints
the edited lines.

I've tried with a "realistic" resolv.conf (since mine hasn't any
"domain" lines):

$ cat myresolv.conf
domain hanskalabs.net
nameserver 192.168.1.1
$

Then I've executed that command against my custom file:

$ awk '$1=="domain"&&ARGV[2]!=""{$2=ARGV[2]}{print}' resolv.conf web.it
domain web.it
nameserver 192.168.1.1
awk: (FILENAME=resolv.conf FNR=2) fatale: non riesco ad aprire file
`web.it' in lettura (No such file or directory)
$

As you can see from the error message, seems like ARGV[2] _MUST_ be a
file (the exact error message says: "can't open `web.it' file in reading
mode"). And, moreover, it edits only the line starting with "domain".

I think that all this could've been done with sed, and some grep maybe
(maybe only sed!).

I hope I've helped :)

>       Eric

My two cents,
David

-- 
         Linux Registered User #334216
Get FireFox! >> http://snipurl.com/gofoxygo/ <<
Blog         >>  http://www.hanskalabs.net/  <<
Staff        >> http://www.debianizzati.org/ <<
-- 
_______________________________________________
Initng mailing list
[email protected]
http://jw.dyndns.org/mailman/listinfo/initng

Reply via email to