<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Macro definitions in m4 in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/macro-definitions-in-m4/m-p/3740220#M101279</link>
    <description>Hello,&lt;BR /&gt;  &lt;BR /&gt;I haven't done any m4 scripting before.&lt;BR /&gt;Nevertheless, I have been presumptuous enough&lt;BR /&gt;to believe that it only takes a little read of the m4 manpage to get me going.&lt;BR /&gt; &lt;BR /&gt;Not quite...&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;Though this is excercised on a Linux Heartbeat cluster which serves an Apache I think it isn't really OS specific and equally applies to m4 on HP-UX.&lt;BR /&gt;  &lt;BR /&gt;I simply want to define an IP based virtual host container that should bind its listening socket to the current node's IP address.&lt;BR /&gt;Thus I thought this could easily be placed in an m4 template which is to be parsed by m4 through the Heartbeat Apache resource start/stop script right before it fires up the webserver, in order to produce that virtual host container with the fitting IP address.&lt;BR /&gt; &lt;BR /&gt;You might ask what this is good for.&lt;BR /&gt;The productive webserver has its fixed IP address that travels together with the package &lt;BR /&gt;(the same as ServiceGuard's relocative IP).&lt;BR /&gt;This additional webserver is only required for maintenance of the cluster nodes.&lt;BR /&gt;E.g. I mirrored a MiniCPAN (abt. 400MB) which I want to have serviced by the virtual host&lt;BR /&gt;in case should immediate installation of additional CPAN modules be required on the cluster nodes.&lt;BR /&gt; &lt;BR /&gt;Ok, here's the m4 mess I have started with,&lt;BR /&gt;but somehow I think I haven't apprehended the notion of m4 yet.&lt;BR /&gt;I thought it should be possible to simply assign a "macro", very much like a variable in any scripting language, only to be referrenced later.&lt;BR /&gt;But this doesn't work in my definition of get_ip.&lt;BR /&gt;You see, I don't want to repeat the long parsing command to retreive the IP address everywhere in situ where it is required.&lt;BR /&gt; &lt;BR /&gt;When I have run this through m4&lt;BR /&gt;  &lt;BR /&gt;  &lt;BR /&gt; &lt;BR /&gt;# cat vhosts.conf.mc &lt;BR /&gt;define(`get_ip' , /sbin/ifconfig eth0|awk -F: '$1~/inet addr/{print$2}'|tr -cd '[0-9.]')&lt;BR /&gt;&lt;VIRTUALHOST syscmd=""&gt;&lt;BR /&gt;    ServerName  syscmd(/sbin/ifconfig eth0|awk -F: '$1~/inet addr/{print$2}'|tr -cd '[0-9.]'):ifdef(`PO&lt;BR /&gt;RT', `PORT', 80)&lt;BR /&gt;    ServerAdmin root@syscmd(/sbin/ifconfig eth0|awk -F: '$1~/inet addr/{print$2}'|tr -cd '[0-9.]')&lt;BR /&gt;&lt;/VIRTUALHOST&gt;&lt;BR /&gt; &lt;BR /&gt;  &lt;BR /&gt;then this is what I get&lt;BR /&gt; &lt;BR /&gt;  &lt;BR /&gt;# m4 -DPORT=443 vhosts.conf.mc &lt;BR /&gt;  &lt;BR /&gt;&lt;VIRTUALHOST&gt;&lt;/VIRTUALHOST&gt;:443&amp;gt;&lt;BR /&gt;    ServerName  192.168.2.2:443&lt;BR /&gt;    ServerAdmin root@192.168.2.2&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;So how do m4 definitions are applied correctly?&lt;BR /&gt; &lt;BR /&gt;Regards&lt;BR /&gt;Ralph&lt;BR /&gt;</description>
    <pubDate>Mon, 27 Feb 2006 12:44:37 GMT</pubDate>
    <dc:creator>Ralph Grothe</dc:creator>
    <dc:date>2006-02-27T12:44:37Z</dc:date>
    <item>
      <title>Macro definitions in m4</title>
      <link>https://community.hpe.com/t5/operating-system-linux/macro-definitions-in-m4/m-p/3740220#M101279</link>
      <description>Hello,&lt;BR /&gt;  &lt;BR /&gt;I haven't done any m4 scripting before.&lt;BR /&gt;Nevertheless, I have been presumptuous enough&lt;BR /&gt;to believe that it only takes a little read of the m4 manpage to get me going.&lt;BR /&gt; &lt;BR /&gt;Not quite...&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;Though this is excercised on a Linux Heartbeat cluster which serves an Apache I think it isn't really OS specific and equally applies to m4 on HP-UX.&lt;BR /&gt;  &lt;BR /&gt;I simply want to define an IP based virtual host container that should bind its listening socket to the current node's IP address.&lt;BR /&gt;Thus I thought this could easily be placed in an m4 template which is to be parsed by m4 through the Heartbeat Apache resource start/stop script right before it fires up the webserver, in order to produce that virtual host container with the fitting IP address.&lt;BR /&gt; &lt;BR /&gt;You might ask what this is good for.&lt;BR /&gt;The productive webserver has its fixed IP address that travels together with the package &lt;BR /&gt;(the same as ServiceGuard's relocative IP).&lt;BR /&gt;This additional webserver is only required for maintenance of the cluster nodes.&lt;BR /&gt;E.g. I mirrored a MiniCPAN (abt. 400MB) which I want to have serviced by the virtual host&lt;BR /&gt;in case should immediate installation of additional CPAN modules be required on the cluster nodes.&lt;BR /&gt; &lt;BR /&gt;Ok, here's the m4 mess I have started with,&lt;BR /&gt;but somehow I think I haven't apprehended the notion of m4 yet.&lt;BR /&gt;I thought it should be possible to simply assign a "macro", very much like a variable in any scripting language, only to be referrenced later.&lt;BR /&gt;But this doesn't work in my definition of get_ip.&lt;BR /&gt;You see, I don't want to repeat the long parsing command to retreive the IP address everywhere in situ where it is required.&lt;BR /&gt; &lt;BR /&gt;When I have run this through m4&lt;BR /&gt;  &lt;BR /&gt;  &lt;BR /&gt; &lt;BR /&gt;# cat vhosts.conf.mc &lt;BR /&gt;define(`get_ip' , /sbin/ifconfig eth0|awk -F: '$1~/inet addr/{print$2}'|tr -cd '[0-9.]')&lt;BR /&gt;&lt;VIRTUALHOST syscmd=""&gt;&lt;BR /&gt;    ServerName  syscmd(/sbin/ifconfig eth0|awk -F: '$1~/inet addr/{print$2}'|tr -cd '[0-9.]'):ifdef(`PO&lt;BR /&gt;RT', `PORT', 80)&lt;BR /&gt;    ServerAdmin root@syscmd(/sbin/ifconfig eth0|awk -F: '$1~/inet addr/{print$2}'|tr -cd '[0-9.]')&lt;BR /&gt;&lt;/VIRTUALHOST&gt;&lt;BR /&gt; &lt;BR /&gt;  &lt;BR /&gt;then this is what I get&lt;BR /&gt; &lt;BR /&gt;  &lt;BR /&gt;# m4 -DPORT=443 vhosts.conf.mc &lt;BR /&gt;  &lt;BR /&gt;&lt;VIRTUALHOST&gt;&lt;/VIRTUALHOST&gt;:443&amp;gt;&lt;BR /&gt;    ServerName  192.168.2.2:443&lt;BR /&gt;    ServerAdmin root@192.168.2.2&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;So how do m4 definitions are applied correctly?&lt;BR /&gt; &lt;BR /&gt;Regards&lt;BR /&gt;Ralph&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Feb 2006 12:44:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/macro-definitions-in-m4/m-p/3740220#M101279</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2006-02-27T12:44:37Z</dc:date>
    </item>
  </channel>
</rss>

