<?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 Re: Mass configuration file modification in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Mass-configuration-file-modification/m-p/25044#M1511</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;...or use excel to add few columns to CSV, upload to management server, run&amp;nbsp;"dos2unix /var/log/script.txt" on it...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Jan 2018 15:15:48 GMT</pubDate>
    <dc:creator>Vladimir</dc:creator>
    <dc:date>2018-01-24T15:15:48Z</dc:date>
    <item>
      <title>Mass configuration file modification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Mass-configuration-file-modification/m-p/25043#M1510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a mass configuration file for adding new host objects with different values and fitting name conventions.&lt;/P&gt;&lt;P&gt;In following configuration line, the variables "AAAAA", "BBBB", "XYZ" and "WWWWWW" should be replaced with values from a CSV oder text file:&lt;/P&gt;&lt;P&gt;add host name "&lt;EM&gt;&lt;STRONG&gt;AAAAA&lt;/STRONG&gt;&lt;/EM&gt;-node-sv&lt;EM&gt;&lt;STRONG&gt;BBBB&lt;/STRONG&gt;&lt;/EM&gt;vh01" ip-address "10.&lt;EM&gt;&lt;STRONG&gt;XYZ&lt;/STRONG&gt;&lt;/EM&gt;.0.8" color "&lt;EM&gt;&lt;STRONG&gt;WWWWWW&lt;/STRONG&gt;&lt;/EM&gt;" groups.1 "Group-Vcenter"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result should be like this:&lt;/P&gt;&lt;P&gt;add host name "G1AT1-node-svAT1vh01" ip-address "10.50.0.8" color "Red" groups.1 "Group-Vcenter"&lt;BR /&gt;add host name "G1AT2-node-svAT2vh01" ip-address "10.51.0.8" color "Red" groups.1 "Group-Vcenter"&lt;BR /&gt;add host name "G2DE1-node-svDE1vh01" ip-address "10.66.0.8" color "Blue" groups.1 "Group-Vcenter"&lt;BR /&gt;add host name "G2FR1-node-svFR1vh01" ip-address "10.67.0.8" color "Blue" groups.1 "Group-Vcenter"&lt;BR /&gt;add host name "G3US1-node-svUS1vh01" ip-address "10.99.0.8" color "Orange" groups.1 "Group-Vcenter"&lt;BR /&gt;add host name "G3CN1-node-svCN1vh01" ip-address "10.98.0.8" color "Orange" groups.1 "Group-Vcenter"&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know how to create a bash script, which changes one variable like the following in a loop. But i have no idea how to adapt this to meet my multi variable change requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;while read p; do&lt;BR /&gt;&amp;nbsp; &amp;nbsp; blabla $p&lt;BR /&gt;&amp;nbsp;done &amp;lt; table.txt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Bernhard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jan 2018 11:58:20 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Mass-configuration-file-modification/m-p/25043#M1510</guid>
      <dc:creator>Bernhard_Sayer</dc:creator>
      <dc:date>2018-01-24T11:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Mass configuration file modification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Mass-configuration-file-modification/m-p/25044#M1511</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;...or use excel to add few columns to CSV, upload to management server, run&amp;nbsp;"dos2unix /var/log/script.txt" on it...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jan 2018 15:15:48 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Mass-configuration-file-modification/m-p/25044#M1511</guid>
      <dc:creator>Vladimir</dc:creator>
      <dc:date>2018-01-24T15:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Mass configuration file modification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Mass-configuration-file-modification/m-p/25045#M1512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;awk&lt;/STRONG&gt; is your friend. It is possible to make a one-liner but for clarity i did it long way &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.checkpoint.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;Assuming your CSV file looks like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AAAAA,BBBB,XYZ,WWWWWW&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;while read line; do&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;# Read each parameter into own variable&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;place1=`echo $line | awk -F, '{print $1}'`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;place2=`echo $line | awk -F, '{print $2}'`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;place3=`echo $line | awk -F, '{print $3}'`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;place4=`echo $line | awk -F, '{print $4}'`&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;cmdline="add host name \"${place1}-node-sv${place2}vh01\" ip-address \"10.${place3}.0.8\" color \"${place4}\" groups.1 \"Group-Vcenter\""&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&lt;EM&gt;then you can use $cmdline string for running the command&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;done &amp;lt; inputfile&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;google awk samples &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.checkpoint.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&amp;nbsp;I haven't tested it but gives you idea &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.checkpoint.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jan 2018 06:01:43 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Mass-configuration-file-modification/m-p/25045#M1512</guid>
      <dc:creator>Kaspars_Zibarts</dc:creator>
      <dc:date>2018-01-25T06:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Mass configuration file modification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Mass-configuration-file-modification/m-p/25046#M1513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did it successful today as follows:&lt;/P&gt;&lt;P&gt;1. Create a CSV file "&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;name-ip-values.csv&lt;/SPAN&gt;" with the required values of IP, Name, Color:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;200;G0AT0;dark gray&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; ... .&lt;/P&gt;&lt;P&gt;2. Create a template file "template.txt" which includes all commands with variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mgmt_cli add host name "AAAAA-node-svh01" ip-address "10.XYZ.0.8" color "WWWWWW"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; .. .&lt;/P&gt;&lt;P&gt;3. Create my first powerful bash script &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;EM&gt;#/bin/bash!&lt;/EM&gt;&lt;/P&gt;&lt;DIV style="padding-left: 30px;"&gt;&lt;EM&gt;IFS='\;'&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV style="padding-left: 30px;"&gt;&lt;EM&gt;while read IP SITE COLOR&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;do&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sed 's/XYZ/'"$IP"'/g ;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s/AAAAA/'"$SITE"'/g ;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s/WWWWWW/'"$COLOR"'/g' template.txt &amp;gt;&amp;gt; output-clish.conf&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV style="padding-left: 30px;"&gt;&lt;EM&gt;done &amp;lt; name-ip-values.csv&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;4. Run&amp;nbsp;&lt;SPAN style="text-align: left; color: #3d3d3d; text-transform: none; line-height: 25.95px; text-indent: 0px; letter-spacing: normal; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-variant: normal; font-weight: 400; text-decoration: none; word-spacing: 0px; display: inline !important; white-space: normal; orphans: 2; float: none; -webkit-text-stroke-width: 0px; background-color: transparent;"&gt;output-clish.conf&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="text-align: left; color: #3d3d3d; text-transform: none; line-height: 25.95px; text-indent: 0px; letter-spacing: normal; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-variant: normal; font-weight: 400; text-decoration: none; word-spacing: 0px; display: inline !important; white-space: normal; orphans: 2; float: none; -webkit-text-stroke-width: 0px; background-color: transparent;"&gt;5. Happy &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="padding-left: 30px;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Feb 2018 19:17:13 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Mass-configuration-file-modification/m-p/25046#M1513</guid>
      <dc:creator>Bernhard_Sayer</dc:creator>
      <dc:date>2018-02-02T19:17:13Z</dc:date>
    </item>
  </channel>
</rss>

