<?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: help with a script in General Topics</title>
    <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123499#M22855</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thank you. here is the script now, but it still do the same thing - ignore the hostname and only writes the date as the filename.&lt;/P&gt;&lt;P&gt;[Expert@fwm-nihuli:0]# cat gws_backup.sh&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;source /opt/CPshrd-R80.40/tmp/.CPprofile.sh&lt;BR /&gt;for dest in $(&amp;lt;/var/log/scripts/gws_list.txt); do&lt;BR /&gt;gwhostname=$(cprid_util -server $dest -verbose rexec -rcmd /bin/bash -c "hostname")&lt;BR /&gt;now=$(date +"%m_%d_%Y").txt&lt;BR /&gt;cprid_util -server $dest -verbose rexec -rcmd /bin/clish -c "show configuration" &amp;gt; /var/log/gws_backup/$gwhostname_$now&lt;BR /&gt;done&lt;/P&gt;&lt;P&gt;as for the option to run it on every gw. i used to do that, but it's have to maintain. as i have tens of gws.&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jul 2021 12:13:10 GMT</pubDate>
    <dc:creator>Amir_Arama</dc:creator>
    <dc:date>2021-07-11T12:13:10Z</dc:date>
    <item>
      <title>help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123488#M22849</link>
      <description>&lt;P&gt;Hi, i would love if someone can help me with this script. it used for backup clish configuration of all GWs remotely from mgmt, save i to file and upload to ftp server. i guess it's something simple to those familiar with bash more than i do.&lt;/P&gt;&lt;P&gt;it was working fine, by creating seperate file for each gw which GWName_Date.txt filename. but lately (maybe from some ver upgrade) it failed to save the filename with $hostname, so it's only save it with the date like 11.7.21.txt, and this cause that each time it override this file, because all files get the same name. if i just run from mgmt&amp;nbsp;&amp;nbsp;cprid_util -server&amp;nbsp; x.x.x.x -verbose rexec -rcmd /bin/bash -c "hostname" it brings the correct hosname. what can be the problem here? how can i fix it?&lt;/P&gt;&lt;P&gt;thx!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#!/bin/sh&lt;BR /&gt;source /opt/CPshrd-R80.40/tmp/.CPprofile.sh&lt;BR /&gt;for dest in $(&amp;lt;/var/log/scripts/gws_list.txt); do&lt;BR /&gt;hostname=`cprid_util -server $dest -verbose rexec -rcmd /bin/bash -c "hostname"`&lt;BR /&gt;now=$(date +"%m_%d_%Y").txt&lt;BR /&gt;cprid_util -server $dest -verbose rexec -rcmd /bin/clish -c "show configuration" &amp;gt; /var/log/gws_backup/$hostname_$now&lt;BR /&gt;done&lt;/P&gt;&lt;P&gt;.........ftp commands.....&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;rm /var/log/gws_backup/*&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 09:31:16 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123488#M22849</guid>
      <dc:creator>Amir_Arama</dc:creator>
      <dc:date>2021-07-11T09:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123495#M22852</link>
      <description>&lt;P&gt;1. replace&amp;nbsp;&lt;SPAN&gt;#!/bin/sh with&amp;nbsp;#!/bin/bash&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. if still not working, try to rename "hostname" with something else, like "gw_hostname" and save it as variable as you have for date:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;gw_hostname=$(cprid_util -server $dest -verbose rexec -rcmd /bin/bash -c "hostname")&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;do not forget to replace new variable of hostname in last cprid_util command&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;PS: I suggest to do not use exact path, like you have for source command. If you upgrade to another version (to R81.x), you will need to replace the path in the source command (use $FWDIR instead).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 11:47:34 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123495#M22852</guid>
      <dc:creator>JozkoMrkvicka</dc:creator>
      <dc:date>2021-07-11T11:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123496#M22853</link>
      <description>&lt;P&gt;Jozko is 100% right...that was actually first thing I noticed as well. Let us know if that works.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 11:49:39 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123496#M22853</guid>
      <dc:creator>the_rock</dc:creator>
      <dc:date>2021-07-11T11:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123497#M22854</link>
      <description>&lt;P&gt;By the way, another way would be to schedule cron job at specific date on every affected gateway to run command "clish -c 'save configuration &amp;lt;PATH&amp;gt;' "&lt;/P&gt;
&lt;P&gt;and then just transfer the backup file to ftp server.&lt;/P&gt;
&lt;P&gt;There are plenty of options how to reach the goal of every script &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 11:59:14 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123497#M22854</guid>
      <dc:creator>JozkoMrkvicka</dc:creator>
      <dc:date>2021-07-11T11:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123499#M22855</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thank you. here is the script now, but it still do the same thing - ignore the hostname and only writes the date as the filename.&lt;/P&gt;&lt;P&gt;[Expert@fwm-nihuli:0]# cat gws_backup.sh&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;source /opt/CPshrd-R80.40/tmp/.CPprofile.sh&lt;BR /&gt;for dest in $(&amp;lt;/var/log/scripts/gws_list.txt); do&lt;BR /&gt;gwhostname=$(cprid_util -server $dest -verbose rexec -rcmd /bin/bash -c "hostname")&lt;BR /&gt;now=$(date +"%m_%d_%Y").txt&lt;BR /&gt;cprid_util -server $dest -verbose rexec -rcmd /bin/clish -c "show configuration" &amp;gt; /var/log/gws_backup/$gwhostname_$now&lt;BR /&gt;done&lt;/P&gt;&lt;P&gt;as for the option to run it on every gw. i used to do that, but it's have to maintain. as i have tens of gws.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 12:13:10 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123499#M22855</guid>
      <dc:creator>Amir_Arama</dc:creator>
      <dc:date>2021-07-11T12:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123505#M22856</link>
      <description>&lt;P&gt;Is file&amp;nbsp;&lt;SPAN&gt;/var/log/scripts/gws_list.txt present and NOT empty?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;are you getting any output from variable "dest" ? try to add "echo $dest" in the loop to see if this will give you desired value (the IPs or hostnames).&lt;/P&gt;
&lt;P&gt;Maybe that "for" is not working properly.&lt;/P&gt;
&lt;P&gt;Try to use following instead:&lt;/P&gt;
&lt;PRE class="lang-sh s-code-block"&gt;&lt;CODE class="hljs language-bash"&gt;&lt;SPAN class="hljs-keyword"&gt;while&lt;/SPAN&gt; &lt;SPAN class="hljs-built_in"&gt;read&lt;/SPAN&gt; dest; &lt;SPAN class="hljs-keyword"&gt;do&lt;/SPAN&gt;
  &lt;SPAN class="hljs-built_in"&gt;echo&lt;/SPAN&gt; &lt;SPAN class="hljs-string"&gt;"&lt;SPAN class="hljs-variable"&gt;$dest&lt;/SPAN&gt;"&lt;BR /&gt;&lt;/SPAN&gt;  . . . 
&lt;SPAN class="hljs-keyword"&gt;done&lt;/SPAN&gt; &amp;lt;&lt;SPAN&gt;/var/log/scripts/gws_list.txt&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 12:27:55 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123505#M22856</guid>
      <dc:creator>JozkoMrkvicka</dc:creator>
      <dc:date>2021-07-11T12:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123506#M22857</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thank you so much for your assistance.&amp;nbsp;unfortunately i don't have much knowledge in bash scripts so i don't know how to complete your ". . ." if you can write all the section as it should be so i can copy &amp;amp; paste it, i will appreciate it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;as for the dest, i know it's working in some way because when i tail the output file ($date.txt)&amp;nbsp; whlie it runs i can see that it go over the FWs(IPS) list from the /&lt;SPAN&gt;var/log/scripts/gws_list.txt file(yes it's exist). so the file is replaced but it run on all the gws list and write their configuration to the file.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 12:44:27 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123506#M22857</guid>
      <dc:creator>Amir_Arama</dc:creator>
      <dc:date>2021-07-11T12:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123522#M22863</link>
      <description>&lt;P&gt;&lt;SPAN&gt;#!/bin/bash&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;source /opt/CPshrd-R80.40/tmp/.CPprofile.sh&lt;/SPAN&gt;&lt;BR /&gt;while read dest; do&lt;BR /&gt;echo "$dest"&lt;BR /&gt;&lt;SPAN&gt;gwhostname=$(cprid_util -server $dest -verbose rexec -rcmd /bin/bash -c "hostname")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;now=$(date +"%m_%d_%Y").txt&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cprid_util -server $dest -verbose rexec -rcmd /bin/clish -c "show configuration" &amp;gt; /var/log/gws_backup/$gwhostname_$now&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;done &amp;lt;/var/log/scripts/gws_list.txt&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 13:28:58 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123522#M22863</guid>
      <dc:creator>JozkoMrkvicka</dc:creator>
      <dc:date>2021-07-11T13:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123523#M22864</link>
      <description>&lt;P&gt;i copied it exactly, and the result is the same. output file name ignoring hostname.&lt;/P&gt;&lt;P&gt;only now when running it, i can see output on the screen with the IP's of the GWs it working on live:&lt;/P&gt;&lt;P&gt;#GWS_list&lt;/P&gt;&lt;P&gt;x.x.x.x&lt;BR /&gt;x.x.x.x&lt;BR /&gt;x.x.x.x&lt;BR /&gt;x.x.x.x&lt;BR /&gt;x.x.x.x&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 13:41:25 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123523#M22864</guid>
      <dc:creator>Amir_Arama</dc:creator>
      <dc:date>2021-07-11T13:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123524#M22865</link>
      <description>&lt;P&gt;it didn't change the result. the only change was that on the window i run the script i see live output that goes line by line from the gws_list.txt file, so i see on which gw it's working at any moment, but the output filename still goes without hostname..&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 14:16:12 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123524#M22865</guid>
      <dc:creator>Amir_Arama</dc:creator>
      <dc:date>2021-07-11T14:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123712#M22880</link>
      <description>&lt;P&gt;&lt;SPAN&gt;#!/bin/bash&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;source /opt/CPshrd-R80.40/tmp/.CPprofile.sh&lt;/SPAN&gt;&lt;BR /&gt;while read dest; do&lt;BR /&gt;&lt;SPAN&gt;gwhostname=$(cprid_util -server $dest -verbose rexec -rcmd /bin/bash -c "hostname")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;now=$(date +"%m_%d_%Y").txt&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cprid_util -server $dest -verbose rexec -rcmd /bin/clish -c "show configuration" &amp;gt; /var/log/gws_backup/"$gwhostname"_"$now"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;done &amp;lt;/var/log/scripts/gws_list.txt&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 10:02:59 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123712#M22880</guid>
      <dc:creator>JozkoMrkvicka</dc:creator>
      <dc:date>2021-07-13T10:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: help with a script</title>
      <link>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123730#M22883</link>
      <description>&lt;P&gt;It worked!&lt;/P&gt;&lt;P&gt;You are the best&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 16:57:45 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/help-with-a-script/m-p/123730#M22883</guid>
      <dc:creator>Amir_Arama</dc:creator>
      <dc:date>2021-07-13T16:57:45Z</dc:date>
    </item>
  </channel>
</rss>

