Koozali.org: home of the SME Server

dhcpd.conf expand-template error?

Offline kryptos

  • *****
  • 245
  • +0/-0
dhcpd.conf expand-template error?
« on: April 12, 2010, 09:20:56 AM »
Hello,

I just brought this problem if mine. I need to tweak some configuration on dhcpd.conf to satisfy what I need on my network. I need to redirect some of the network station to use a different gateways as the current dhcp gives out while others uses the default gateway. Basically I have created a new custom template from /etc/e-smith/templates-custom/etc/dhcpd.conf and from there create this file 99group

Code: [Select]
group {
        option domain-name "vpnisl2";
        option routers 192.168.102.2;
        option domain-name-servers 192.168.102.2;
        host lab {
        hardware ethernet 00:24:82:4C:5b:ce; fixed-address 192.168.102.4;}
}


Then I expand it by: #expand-template /etc/dhcpd.conf

And I got this error after

Code: [Select]
# expand-template /etc/dhcpd.conf
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: String found where operator expected at /etc/e-smith  /templates-custom//etc/dhcpd.conf/99group line 2, near "name "vpnisl2""
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group:       (Do you need to predeclare name?)
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Number found where operator expected at /etc/e-smith  /templates-custom//etc/dhcpd.conf/99group line 4, near "servers 192.168.102.2"
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group:       (Do you need to predeclare servers?)
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Bareword found where operator expected at /etc/e-smi  th/templates-custom//etc/dhcpd.conf/99group line 6, near "4C"
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group:       (Missing operator before C?)
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Bareword found where operator expected at /etc/e-smi  th/templates-custom//etc/dhcpd.conf/99group line 6, near "5b"
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group:       (Missing operator before b?)
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Unquoted string "b" may clash with future reserved w  ord at /etc/e-smith/templates-custom//etc/dhcpd.conf/99group line 6.
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Unquoted string "ce" may clash with future reserved   word at /etc/e-smith/templates-custom//etc/dhcpd.conf/99group line 6.
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Unquoted string "fixed" may clash with future reserv  ed word at /etc/e-smith/templates-custom//etc/dhcpd.conf/99group line 6.
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Number found where operator expected at /etc/e-smith  /templates-custom//etc/dhcpd.conf/99group line 6, near "address 192.168.102.4"
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group:       (Do you need to predeclare address?)
ERROR in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Program fragment delivered error <<syntax error at /et  c/e-smith/templates-custom//etc/dhcpd.conf/99group line 2, near "name "vpnisl2""
syntax error at /etc/e-smith/templates-custom//etc/dhcpd.conf/99group line 4, near "servers 192.168.102.2"
syntax error at /etc/e-smith/templates-custom//etc/dhcpd.conf/99group line 6, near "00:"
syntax error at /etc/e-smith/templates-custom//etc/dhcpd.conf/99group line 6, near "address 192.168.102.4">> at templa  te line 1
ERROR: Template processing failed for //etc/dhcpd.conf: 13 fragments generated warnings, 1 fragment generated errors
 at /sbin/e-smith/expand-template line 45


Can anyone explain why I have this error?

Regards,
Rocel

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: dhcpd.conf expand-template error?
« Reply #1 on: April 12, 2010, 09:35:51 AM »
hi

Code: [Select]

$OUT .= "group {\n";
$OUT .= "        option domain-name \"vpnisl2\";\n";
$OUT .= "        option routers 192.168.102.2;\n";
$OUT .= "       option domain-name-servers 192.168.102.2;\n";
$OUT .= "        host lab {\n";
$OUT .= "        hardware ethernet 00:24:82:4C:5b:ce; fixed-address 192.168.102.4;}\n";
$OUT .= "}\n";

should work, not tested, let us know

HTH

Offline kryptos

  • *****
  • 245
  • +0/-0
Re: dhcpd.conf expand-template error?
« Reply #2 on: April 12, 2010, 10:22:27 AM »
hi

Code: [Select]

$OUT .= "group {\n";
$OUT .= "        option domain-name \"vpnisl2\";\n";
$OUT .= "        option routers 192.168.102.2;\n";
$OUT .= "       option domain-name-servers 192.168.102.2;\n";
$OUT .= "        host lab {\n";
$OUT .= "        hardware ethernet 00:24:82:4C:5b:ce; fixed-address 192.168.102.4;}\n";
$OUT .= "}\n";

should work, not tested, let us know

HTH


Change the content of file 99group and I have this error:

Code: [Select]
# expand-template /etc/dhcpd.conf
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Unquoted strin                                      g "n" may clash with future reserved word at /etc/e-smith/templates-custom//etc/                                      dhcpd.conf/99group line 1.
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: String found w                                      here operator expected at /etc/e-smith/templates-custom//etc/dhcpd.conf/99group                                       line 2, near "n";
$OUT .= ""
  (Might be a runaway multi-line "" string starting on line 1)
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Bareword found                                       where operator expected at /etc/e-smith/templates-custom//etc/dhcpd.conf/99grou                                      p line 2, near "";
$OUT .= "        option"
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group:       (Missing                                       operator before option?)
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Backslash foun                                      d where operator expected at /etc/e-smith/templates-custom//etc/dhcpd.conf/99gro                                      up line 2, near "name \"
WARNING in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group:       (Do you                                       need to predeclare name?)
ERROR in /etc/e-smith/templates-custom//etc/dhcpd.conf/99group: Program fragment                                       delivered error <<Can't find string terminator '"' anywhere before EOF at /etc/                                      e-smith/templates-custom//etc/dhcpd.conf/99group line 7.>> at template line 1
ERROR: Template processing failed for //etc/dhcpd.conf: 6 fragments generated wa                                      rnings, 1 fragment generated errors
 at /sbin/e-smith/expand-template line 45




Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: dhcpd.conf expand-template error?
« Reply #3 on: April 12, 2010, 02:37:02 PM »
{ and } are special characters within template fragments. You will need to use \{ and \} for them to work correctly.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: dhcpd.conf expand-template error?
« Reply #4 on: April 12, 2010, 02:56:43 PM »
thank you Charlie..

I'm pretty confused as I'm scripting in vbscript, javascript, php.. :-)

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: dhcpd.conf expand-template error?
« Reply #5 on: April 12, 2010, 04:25:37 PM »

Code: [Select]
group {
        option domain-name "vpnisl2";
        option routers 192.168.102.2;
        option domain-name-servers 192.168.102.2;
        host lab {
        hardware ethernet 00:24:82:4C:5b:ce; fixed-address 192.168.102.4;}
}

Change it to:

Code: [Select]
group \{
        option domain-name "vpnisl2";
        option routers 192.168.102.2;
        option domain-name-servers 192.168.102.2;
        host lab \{
        hardware ethernet 00:24:82:4C:5b:ce; fixed-address 192.168.102.4;\}
\}

The problem is that the perl interpreter is trying to interpret what it finds inside the {} blocks in your template, but what it finds there is not perl.

Offline kryptos

  • *****
  • 245
  • +0/-0
Re: dhcpd.conf expand-template error?
« Reply #6 on: April 13, 2010, 02:48:10 AM »
Change it to:

Code: [Select]
group \{
        option domain-name "vpnisl2";
        option routers 192.168.102.2;
        option domain-name-servers 192.168.102.2;
        host lab \{
        hardware ethernet 00:24:82:4C:5b:ce; fixed-address 192.168.102.4;\}
\}

The problem is that the perl interpreter is trying to interpret what it finds inside the {} blocks in your template, but what it finds there is not perl.


It works great thanks a lot Charlie and Stef. I've learned something new.

Regards,
Rocel