<?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: Clish config-state check from expert mode? in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Clish-config-state-check-from-expert-mode/m-p/256655#M9236</link>
    <description>&lt;P&gt;Thank you for your efforts, even though you weren't able to avoid &lt;CODE&gt;clish -c&lt;/CODE&gt; either. Clish writes changes to the main memory only it seems, which can be read out via&amp;nbsp;&lt;A href="https://support.checkpoint.com/results/sk/sk92770" target="_self"&gt;dbget&lt;/A&gt;. I haven't yet found a way to check whether the latest Clish changes have already been written to &lt;CODE&gt;/config/db&lt;/CODE&gt; without using &lt;CODE&gt;clish -c&lt;/CODE&gt; as this command is also quite slow, especially when my script consecutively runs multiple &lt;CODE&gt;clish -c&lt;/CODE&gt; calls &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;. I decided not to &lt;CODE&gt;grep&lt;/CODE&gt; for "&lt;EM&gt;save config&lt;/EM&gt;" in &lt;CODE&gt;/home/admin/.clish_history&lt;/CODE&gt; as this file is not written in realtime.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Sep 2025 12:38:19 GMT</pubDate>
    <dc:creator>Danny</dc:creator>
    <dc:date>2025-09-05T12:38:19Z</dc:date>
    <item>
      <title>Clish config-state check from expert mode?</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Clish-config-state-check-from-expert-mode/m-p/256048#M9202</link>
      <description>&lt;P&gt;In Gaia &lt;A href="https://sc1.checkpoint.com/documents/R82/WebAdminGuides/EN/CP_R82_Gaia_AdminGuide/Content/Topics-GAG/Gaia-Clish-Expert-Mode.htm" target="_self"&gt;expert mode&lt;/A&gt;, is it possible to check if a &lt;A href="https://sc1.checkpoint.com/documents/R81/WebAdminGuides/EN/CP_R81_Gaia_AdminGuide/Topics-GAG/Gaia-Clish-Commands.htm" target="_self"&gt;Clish&lt;/A&gt; configuration is &lt;STRONG&gt;unsaved&lt;/STRONG&gt; without running &lt;CODE&gt;clish -c&lt;/CODE&gt;?&lt;BR /&gt;This is to avoid any possible config lock errors. I'd prefer something like a quick &lt;CODE&gt;grep&lt;/CODE&gt; check, if possible.&lt;BR /&gt;&lt;BR /&gt;Current command:&lt;BR /&gt;&lt;CODE&gt;[Expert@firewall:0]# clish -c "show &lt;STRONG&gt;config-state&lt;/STRONG&gt;"&lt;/CODE&gt; &lt;BR /&gt;Output:&lt;BR /&gt;&lt;CODE&gt;CLINFR0771 Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.&lt;BR /&gt;1_01:&lt;BR /&gt;&lt;STRONG&gt;unsaved&lt;BR /&gt;&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2025 12:22:25 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Clish-config-state-check-from-expert-mode/m-p/256048#M9202</guid>
      <dc:creator>Danny</dc:creator>
      <dc:date>2025-09-05T12:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Clish config-state check from expert mode?</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Clish-config-state-check-from-expert-mode/m-p/256615#M9235</link>
      <description>&lt;P&gt;I'm not aware of a good way to check this outside of clish. This is the best I've been able to do:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[Expert@DallasSC]# clish -c "show config-state" | egrep -v "^(CLINFR0771|$)"
saved
[Expert@DallasSC]# clish -c "set ntp active off"
[Expert@DallasSC]# clish -c "show config-state" | egrep -v "^(CLINFR0771|$)"
unsaved&lt;/LI-CODE&gt;
&lt;P&gt;I started another SSH session and went into clish after making the NTP change and before running the second 'show config-state', so the database was locked by that session.&lt;/P&gt;
&lt;P&gt;Fairly ugly. The egrep filters out the "Config lock is owned by ..." line and the blank line it prints. Easy enough to turn into a boolean value by piping it to 'grep -q "unsaved"'. Exit code 0 for unsaved, 1 for saved. 'grep -qv "unsaved"' flips the logic: 1 for unsaved, 0 for saved. Here's an example. In each output block, the first is from a bare 'clish -c "show config-state"', the second is from the command above, and the third uses the 'grep -dv "unsaved"' to demonstrate turning it into something you can use directly with test.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[Expert@DallasSC]# echo "----------";clish -c "show config-state";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)" | grep -qv unsaved;echo $?
----------
saved
----------
saved
----------
0

[Expert@DallasSC]# clish -c "set ntp active off"

[Expert@DallasSC]# echo "----------";clish -c "show config-state";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)" | grep -qv unsaved;echo $?
----------
unsaved
----------
unsaved
----------
1

[Expert@DallasSC]# echo "----------";clish -c "show config-state";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)" | grep -qv unsaved;echo $?
----------
CLINFR0771  Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.
unsaved
----------
unsaved
----------
1&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Sep 2025 20:09:02 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Clish-config-state-check-from-expert-mode/m-p/256615#M9235</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2025-09-04T20:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Clish config-state check from expert mode?</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Clish-config-state-check-from-expert-mode/m-p/256655#M9236</link>
      <description>&lt;P&gt;Thank you for your efforts, even though you weren't able to avoid &lt;CODE&gt;clish -c&lt;/CODE&gt; either. Clish writes changes to the main memory only it seems, which can be read out via&amp;nbsp;&lt;A href="https://support.checkpoint.com/results/sk/sk92770" target="_self"&gt;dbget&lt;/A&gt;. I haven't yet found a way to check whether the latest Clish changes have already been written to &lt;CODE&gt;/config/db&lt;/CODE&gt; without using &lt;CODE&gt;clish -c&lt;/CODE&gt; as this command is also quite slow, especially when my script consecutively runs multiple &lt;CODE&gt;clish -c&lt;/CODE&gt; calls &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;. I decided not to &lt;CODE&gt;grep&lt;/CODE&gt; for "&lt;EM&gt;save config&lt;/EM&gt;" in &lt;CODE&gt;/home/admin/.clish_history&lt;/CODE&gt; as this file is not written in realtime.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2025 12:38:19 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Clish-config-state-check-from-expert-mode/m-p/256655#M9236</guid>
      <dc:creator>Danny</dc:creator>
      <dc:date>2025-09-05T12:38:19Z</dc:date>
    </item>
  </channel>
</rss>

