<?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: VSX, clish, and bash? in Firewall and Security Management</title>
    <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88972#M8980</link>
    <description>&lt;P&gt;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/27871"&gt;@Bob_Zimmerman&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I understand your pain but it's how it works.&lt;/P&gt;
&lt;P&gt;Following&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/17364"&gt;@Maarten_Sjouw&lt;/a&gt;&amp;nbsp;idea using&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/21670"&gt;@HeikoAnkenbrand&lt;/a&gt;&amp;nbsp;rewrite....&lt;/P&gt;
&lt;P&gt;Create a new "c" script for every context you need:&lt;/P&gt;
&lt;P&gt;##############################################&lt;/P&gt;
&lt;P&gt;echo "echo set virtual-system 4 &amp;gt; /var/log/clish.txt" &amp;gt; /bin/c4&lt;BR /&gt;echo "echo \$@ &amp;gt;&amp;gt; /var/log/clish.txt" &amp;gt;&amp;gt; /bin/c4&lt;BR /&gt;echo "clish -f /var/log/clish.txt" &amp;gt;&amp;gt; /bin/c4&lt;BR /&gt;chmod 770 /bin/c4&lt;/P&gt;
&lt;P&gt;##############################################&lt;/P&gt;
&lt;P&gt;Now you can execute with "c4" any clish command in VS context 4. Do the same for every other context.&lt;/P&gt;
&lt;P&gt;Wolfgang&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jun 2020 06:49:37 GMT</pubDate>
    <dc:creator>Wolfgang</dc:creator>
    <dc:date>2020-06-18T06:49:37Z</dc:date>
    <item>
      <title>VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88925#M8973</link>
      <description>&lt;P&gt;Is there some way to start clish in a particular VSID? I'm tired of switching into a context, doing some troubleshooting, then going into clish to check OSPF neighbors and winding up in VS0.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 15:15:44 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88925#M8973</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2020-06-17T15:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88938#M8974</link>
      <description>&lt;P&gt;set your account as /bin/bash (set user xxx shell /bin/bash)&lt;/P&gt;
&lt;P&gt;then once you log in, you are in expert mode.&lt;/P&gt;
&lt;P&gt;going into different VSID: vsenv &amp;lt;ID&amp;gt;&lt;/P&gt;
&lt;P&gt;checking clish commands: clish -c "&amp;lt;clish command here&amp;gt;" (quotes are part of command)&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 18:16:41 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88938#M8974</guid>
      <dc:creator>JozkoMrkvicka</dc:creator>
      <dc:date>2020-06-17T18:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88939#M8975</link>
      <description>&lt;P&gt;That is, roughly speaking, how I work right now. I don’t know of a way to enter clish for the context I am currently using in bash, though. I don’t see any command line argument for it, and clish clearly ignores /proc/self/vrf when launching a new instance.&lt;/P&gt;&lt;P&gt;clish -c “someCommand” is nice … for running things in VS0. Running multi-line commands like that is irritating, and since clish always goes to VS0 when it launches, all commands in particular VSs would be multi-line.&lt;/P&gt;&lt;P&gt;I’m looking for a way to get into clish for the context I’m currently set to in bash (the other way around would also be good, but less useful to me).&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 19:07:04 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88939#M8975</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2020-06-17T19:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88940#M8976</link>
      <description>&lt;P&gt;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/27871"&gt;@Bob_Zimmerman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;„set virtual-system VSID“ in clish changes &amp;nbsp;your context.&lt;/P&gt;
&lt;P&gt;Another option is to write your needed commands in a small script in the first line with setting the right context and then execute these script via „clish -f filename“ from bash.&lt;/P&gt;
&lt;P&gt;Wolfgang&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 19:11:07 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88940#M8976</guid>
      <dc:creator>Wolfgang</dc:creator>
      <dc:date>2020-06-17T19:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88943#M8977</link>
      <description>&lt;P&gt;I'm aware of how to change the context once in clish. I'm asking for a way to avoid needing to do that.&lt;/P&gt;&lt;P&gt;I'm&amp;nbsp;&lt;EM&gt;already in the VS&lt;/EM&gt;. How do I get clish to recognize this rather than going all amnesiac? For example, if I run:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;vsenv 2&lt;/P&gt;&lt;P&gt;clish -c "show ospf neighbors"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... it shows me the OSPF neighbors for VS0. In what universe is that expected or rational behavior?&lt;/P&gt;&lt;P&gt;Obviously the right thing to do would be for clish to pay attention to the contents of /proc/self/vrf when it launches and to run in that context. Further, it &lt;STRONG&gt;should&lt;/STRONG&gt; do the vsenv stuff in the background when you change VSs in it so if you change VSs in bash, enter clish, change to another VS, then exit clish, your bash session will be in the VS you were in in clish.&amp;nbsp;If there was a way to specify on the command line that I want a clish session in &amp;lt;VSID&amp;gt;, that would be acceptable (though still less than ideal), because I could just alias 'clish' to add '-v $(cat /proc/self/vrf)' to the invocation.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 19:44:22 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88943#M8977</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2020-06-17T19:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88951#M8978</link>
      <description>&lt;P&gt;Use clish -f and put your most used commands in some specific txt files that you can simply call like:&lt;BR /&gt;clish -f ospfneighbors&lt;/P&gt;
&lt;P&gt;On top of that you can use&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/21670"&gt;@HeikoAnkenbrand&lt;/a&gt;'s trick to create a separate command that will use clish -f for a single command, to &lt;A href="https://community.checkpoint.com/t5/General-Topics/CLISH-Commands-in-Expert-Mode-easier/td-p/38466" target="_self"&gt;be found here.&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 21:48:09 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88951#M8978</guid>
      <dc:creator>Maarten_Sjouw</dc:creator>
      <dc:date>2020-06-17T21:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88958#M8979</link>
      <description>Pretty sure this is an RFE.</description>
      <pubDate>Thu, 18 Jun 2020 02:49:23 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88958#M8979</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2020-06-18T02:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88972#M8980</link>
      <description>&lt;P&gt;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/27871"&gt;@Bob_Zimmerman&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I understand your pain but it's how it works.&lt;/P&gt;
&lt;P&gt;Following&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/17364"&gt;@Maarten_Sjouw&lt;/a&gt;&amp;nbsp;idea using&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/21670"&gt;@HeikoAnkenbrand&lt;/a&gt;&amp;nbsp;rewrite....&lt;/P&gt;
&lt;P&gt;Create a new "c" script for every context you need:&lt;/P&gt;
&lt;P&gt;##############################################&lt;/P&gt;
&lt;P&gt;echo "echo set virtual-system 4 &amp;gt; /var/log/clish.txt" &amp;gt; /bin/c4&lt;BR /&gt;echo "echo \$@ &amp;gt;&amp;gt; /var/log/clish.txt" &amp;gt;&amp;gt; /bin/c4&lt;BR /&gt;echo "clish -f /var/log/clish.txt" &amp;gt;&amp;gt; /bin/c4&lt;BR /&gt;chmod 770 /bin/c4&lt;/P&gt;
&lt;P&gt;##############################################&lt;/P&gt;
&lt;P&gt;Now you can execute with "c4" any clish command in VS context 4. Do the same for every other context.&lt;/P&gt;
&lt;P&gt;Wolfgang&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 06:49:37 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/88972#M8980</guid>
      <dc:creator>Wolfgang</dc:creator>
      <dc:date>2020-06-18T06:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/89109#M8981</link>
      <description>&lt;P&gt;Those are the magic words I was looking for.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face_with_tongue:"&gt;😜&lt;/span&gt; My sales team suggested I post here in case it was already possible and they just weren't aware.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 23:51:59 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/89109#M8981</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2020-06-18T23:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/89110#M8982</link>
      <description>&lt;P&gt;Rather than a different script for each VSID hard-coded to go to that VSID, it's easier to just "&lt;FONT face="courier new,courier"&gt;set virtual-system $(cat /proc/self/vrf)&lt;/FONT&gt;".&amp;nbsp;But that gave me an idea for something simple:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#!/bin/env bash
printf "set virtual-system $(cat /proc/self/vrf)\n$(echo "$@")\nexit\n" | clish
echo ""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's not the prettiest, but it automatically works in the current VRF. It's a shame &lt;FONT face="courier new,courier"&gt;clish -c&lt;/FONT&gt; flips out about newlines in the command. Otherwise, it would be possible to do something similar as &lt;FONT face="courier new,courier"&gt;clish -c "$(echo "set virtual-system $(cat /proc/self/vrf)";echo "$@")"&lt;/FONT&gt;, which is slightly more elegant than the printf.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 00:02:58 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/89110#M8982</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2020-06-19T00:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155466#M26494</link>
      <description>&lt;P&gt;Turns out this is now broken in R80.40 and up. Possibly R80.30 as well. clish no longer accepts piped input, and still doesn't accept newlines in the command argument.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 22:24:27 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155466#M26494</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2022-08-22T22:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155484#M26496</link>
      <description>&lt;P&gt;Please use the "clish -c" option without using pipe, the pipe is not officially supported.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 07:22:20 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155484#M26496</guid>
      <dc:creator>Majd_Sharkia</dc:creator>
      <dc:date>2022-08-23T07:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155520#M26506</link>
      <description>&lt;P&gt;Oh, I know. And clish -c is &lt;STRONG&gt;&lt;EM&gt;completely unusable&lt;/EM&gt;&lt;/STRONG&gt;:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[Expert@MyVsxMember1:0]# fw ver
This is Check Point's software version R80.40 - Build 135
[Expert@MyVsxMember1:0]# clish -c "set virtual-system 2;show router-id"
CLINFR0329  Invalid command:'set virtual-system 2;show router-id'.
[Expert@MyVsxMember1:0]# clish -c "set virtual-system 2\nshow router-id" 
CLINFR0329  Invalid command:'set virtual-system 2\nshow router-id'.
[Expert@MyVsxMember1:0]# clish -c "$(echo "set virtual-system 2";echo "show router-id")"
CLINFR0710  Illegal characters
[Expert@MyVsxMember1:0]# printf "set virtual-system 2\nshow router-id\n" | clish
[Expert@MyVsxMember1:0]# &lt;/LI-CODE&gt;
&lt;P&gt;Can't chain multiple commands together, which means you can't get any information from VSs other than 0, which means comparing the configuration between VSX cluster members is excruciatingly manual. It's worse since the config line order in clish is not stable between cluster members, so you have to sort the lines to be able to use diff, but you can't just log your SSH session and sort everything, since that loses which VS has each line.&lt;/P&gt;
&lt;P&gt;Can't use pipes in clish, so it's completely unusable for troubleshooting. I would just use clish -c and pipe it through grep and so on, but again, can't get information from VSs other than 0, making it literally unusable for troubleshooting. For example, there's no way to look for a single entry in the OSPF database of a VS other than 0. No, you have to show the whole OSPF database, then look through it with Notepad or something.&lt;/P&gt;
&lt;P&gt;I'm really irritated about this loss of functionality, and I will be complaining through my sales team soon.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 12:09:57 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155520#M26506</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2022-08-23T12:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155521#M26507</link>
      <description>&lt;P&gt;You can use "clish -f" to run multiple commands, if you don't know how to use you can reach me.&lt;/P&gt;
&lt;P&gt;Anyway, I suggest opening a ticket for CFG to check that.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 12:32:03 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155521#M26507</guid>
      <dc:creator>Majd_Sharkia</dc:creator>
      <dc:date>2022-08-23T12:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155545#M26518</link>
      <description>&lt;P&gt;Yes, but then I have to create a file, write the commands I want to run to the file, run the commands, deal with clish's extraneous output from running commands from a file, then clean up the file afterwards. All to get an approximation of functionality which worked before but which has broken.&lt;/P&gt;
&lt;P&gt;This is the extraneous output I mean:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[Expert@MyVsxMember1:0]# cat clishScript.txt 
set virtual-system 12
show router-id
[Expert@MyVsxMember1:0]# clish -f clishScript.txt 
Context is set to vsid 122 
Processing line 2 out of 2 
Router ID:  10.2.3.4

Done.                                                        
[Expert@MyVsxMember1:0]# clish -f clishScript.txt 2&amp;gt;/dev/null
Context is set to vsid 122 
Processing line 2 out of 2 
Router ID:  10.2.3.4

Done.                                                        
[Expert@MyVsxMember1:0]# clish
MyVsxMember1:0&amp;gt; set virtual-system 12
Context is set to vsid 12
MyVsxMember1:12&amp;gt; show router-id

Router ID:  10.2.3.4

MyVsxMember1:12&amp;gt; &lt;/LI-CODE&gt;
&lt;P&gt;Context is set to vsid 122? Clearly it's printed on top of "Processing line 1 of 2", but are you kidding me? The only reason the router ID doesn't show up as "10.2.3.4&lt;SPAN&gt;t of 2" is that the clish command 'show router-id' prints an otherwise-unnecessary newline first.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The extra output is in STDOUT, so I can't just use 2&amp;gt;/dev/null to discard it.&lt;/P&gt;
&lt;P&gt;The command files don't appear to accept any sort of variable, so if I want to write a script to get the router IDs of all 30 VSs, I have to rewrite the file for every single one. Not insurmountable, but needlessly inconvenient.&lt;/P&gt;
&lt;P&gt;XML output helps with some of this, but there aren't tools on-box to deal with it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Previously, to get the router ID on all of my VSs, I just had to run this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;for vsid in $(ip netns list | cut -d' ' -f3 | sed 's/)//' | sort -g);do vsenv "$vsid" 2&amp;gt;&amp;amp;1 &amp;gt;/dev/null;printf "%5s: " "$vsid";echo "$(printf "set virtual-system $vsid\nshow router-id\n" | clish | grep Router | awk '{print $NF}')";done&lt;/LI-CODE&gt;
&lt;P&gt;It's not the prettiest, but it worked well and is relatively clean. Now I need all that plus file handling.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 20:00:52 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155545#M26518</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2022-08-23T20:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155573#M26524</link>
      <description>&lt;P&gt;I understand your point and we will try to figure out this.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 07:39:49 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/155573#M26524</guid>
      <dc:creator>Majd_Sharkia</dc:creator>
      <dc:date>2022-08-24T07:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/179157#M32838</link>
      <description>&lt;P&gt;Support suggested a sed expression I had not considered:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;sed -E 's/^Processing .+?\r//g'&lt;/LI-CODE&gt;
&lt;P&gt;This works, since the "Processing line X of Y" ends with a carriage return, but not a newline. The expression eats everything from a line starting with Processing to the next carriage return, leaving only the line which was meant to be printed.&lt;/P&gt;
&lt;P&gt;This is a passable workaround, but clish &lt;STRONG&gt;desperately&lt;/STRONG&gt; needs improvement on VSX.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 20:37:44 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/179157#M32838</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2023-04-25T20:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/187892#M34642</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Wrapped your idea's in a little bash script&lt;/P&gt;&lt;P&gt;eclish.sh - support selecting a VS and running multiple commands (comma separated)&lt;BR /&gt;chmod +x eclish.sh (to get it running)&lt;/P&gt;&lt;P&gt;run with -h to help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#!/bin/bash&lt;/P&gt;&lt;P&gt;############################################&lt;BR /&gt;# eclish&lt;BR /&gt;# extand checkpoint "clish" to support VSX and multiple commands&lt;BR /&gt;#&lt;BR /&gt;# &lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/34732"&gt;@By&lt;/a&gt; scriptoman&lt;BR /&gt;#&lt;/P&gt;&lt;P&gt;EFILE=/home/admin/ecmds.txt&lt;BR /&gt;cmds=()&lt;BR /&gt;vsid=0&lt;BR /&gt;&lt;BR /&gt;#Display usage&lt;BR /&gt;function display_help {&lt;BR /&gt;echo "Usage: eclish [OPTIONS]..."&lt;BR /&gt;echo "Extended clish support VS and multiple commands."&lt;BR /&gt;echo&lt;BR /&gt;echo -e "Arguments:"&lt;BR /&gt;echo -e " -v, --vs-id \t\t select virtual system id to run at "&lt;BR /&gt;echo -e " -c, --commands \t command/s to run (comma seperated) "&lt;BR /&gt;echo -e " -f, --file \t\t load command set from file "&lt;BR /&gt;echo -e " -h, --help \t\t display this help"&lt;BR /&gt;echo&lt;BR /&gt;exit&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function set_virtual {&lt;BR /&gt;vsid="$1"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function set_commands {&lt;BR /&gt;IFS=',' read -ra cmds &amp;lt;&amp;lt;&amp;lt; "$1"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function set_file {&lt;BR /&gt;echo "File: $1"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;function create_cmds_file {&lt;BR /&gt;echo "set virtual-system $vsid" &amp;gt; $EFILE&lt;/P&gt;&lt;P&gt;for c in "${cmds[@]}"&lt;BR /&gt;do&lt;BR /&gt;echo $c &amp;gt;&amp;gt; $EFILE&lt;BR /&gt;done&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function eclish {&lt;/P&gt;&lt;P&gt;create_cmds_file&lt;BR /&gt;# cat $EFILE&lt;BR /&gt;clish -f "$EFILE" | sed -E 's/^Processing .+?\r//g'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;parameters=("$@")&lt;BR /&gt;pLength="${#parameters[@]}"&lt;/P&gt;&lt;P&gt;if [[ $pLength -eq 0 ]]; then&lt;BR /&gt;read -p "Enter parameters:" input&lt;BR /&gt;parameters=($input)&lt;BR /&gt;pLength="${#parameters[@]}"&lt;BR /&gt;fi&lt;/P&gt;&lt;P&gt;#echo "Len:$pLength"&lt;/P&gt;&lt;P&gt;pPlace=0&lt;/P&gt;&lt;P&gt;while [[ $pPlace -lt $pLength ]] ; do&lt;BR /&gt;&lt;BR /&gt;case ${parameters[$pPlace]} in&lt;BR /&gt;-v|--vs-id)&lt;BR /&gt;set_virtual "${parameters[($pPlace+1)]}"&lt;BR /&gt;pPlace=$((pPlace + 2))&lt;BR /&gt;;;&lt;BR /&gt;-c|--commands)&lt;BR /&gt;set_commands "${parameters[($pPlace+1)]}"&lt;BR /&gt;pPlace=$((pPlace + 2))&lt;BR /&gt;;;&lt;BR /&gt;-f|--file)&lt;BR /&gt;set_file "${parameters[($pPlace+1)]}"&lt;BR /&gt;pPlace=$((pPlace + 2))&lt;BR /&gt;;;&lt;BR /&gt;-h|--help)&lt;BR /&gt;display_help&lt;BR /&gt;pPlace=$((pPlace + 1))&lt;BR /&gt;;;&lt;BR /&gt;*)&lt;BR /&gt;break&lt;BR /&gt;;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;done&lt;/P&gt;&lt;P&gt;eclish&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 15:29:04 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/187892#M34642</guid>
      <dc:creator>YC</dc:creator>
      <dc:date>2023-07-27T15:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/212338#M40300</link>
      <description>&lt;P&gt;I quasi-solved this with some clever Ansible-fu myself. &amp;nbsp;It's a bit involved, but the meat of it is:&lt;/P&gt;
&lt;P&gt;* Inventory&lt;/P&gt;
&lt;P&gt;1a) if you have a vsx cluster, define ansible hosts for each vsx cluster gateway. &amp;nbsp;Define the IP for "ansible_host: x.x.x.x"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1b) define a logical ansible group for the VSX cluster (VSX_CLUSTER01, with members: gw1, gw2, gw3)&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp;Define each VS as an inventory host - attach 2 variables:&lt;/P&gt;
&lt;P&gt;vs_id: &amp;lt;vsid&amp;gt;&lt;/P&gt;
&lt;P&gt;vsx: &amp;lt;name of the hosting vsx&amp;gt; (either the vsx cluster group name [VSX_CLUSTER01], or single vsx gateway )&lt;/P&gt;
&lt;P&gt;3) I have my inventory set for different groups, but somewhere you want to define the Check Point connection variables&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# cat inventory/group_vars/check_point/vars.yml 
---
ansible_httpapi_validate_certs: false
ansible_httpapi_use_ssl: true
ansible_httpapi_port: "{{ gaia_api_port |default(443) }}"
ansible_network_os: check_point.gaia.checkpoint
...
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Playbooks&lt;/P&gt;
&lt;P&gt;I chose to do this all with Gaia API [yes Gaia API works on VSX, just VS0, which is all we need]&lt;/P&gt;
&lt;P&gt;It's a nested series of loops. &amp;nbsp;Since the target is a VS, and the VS is on a cluster, the playbooks run the same CLISH command on all VSX gateways of the cluster where that VS is hosted. &amp;nbsp;"show ospf neighbors" only returns neighbors on the active VSX gateway for the VS. &amp;nbsp;But you might want "show configuration ospf" to verify configuration evenness.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I loop through the group of VSX gateways for the that VS's hosting VSX, and building the variables as it goes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;main.yml:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;- name: Run CLISH command
  hosts: check_point
  become: false
  gather_facts: false
  connection: httpapi
  serial: 3

  vars:
    ansible_network_os: check_point.gaia.checkpoint
    output_dir: "clish_output/"

  tasks:
  tasks:
    - name: Run CLISH command on gateways
      include_tasks: gaia_clish_cmd.yml
      when: vsx is not defined

    - name: Run CLISH command on VSX VS
      include_tasks: vsx_clish_cmd.yml
      when: vsx is defined
...
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So if 'vsx' is defined for the inventory host, loop through an inventory group with that name (VSX cluster); no i don't have this really set right to work if the VS is on a single-host VSX; i don't have one of those handy at the moment. &amp;nbsp;It's not too hard to figure out how to adapt this, tho.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# cat vsx_clish_cmd.yml 
---
- include_tasks: clish_script_build.yml
  loop: "{{ groups[vsx] }}"
  loop_control:
    label: "{{ vsx_host }}: {{ inventory_hostname }}"
  vars:
    config_file: "{{ vsx_host }}.{{ inventory_hostname }}.clish"
    config_dir: "vs_configs"
    vsx_host: "{{ item }}"

...
&lt;/LI-CODE&gt;
&lt;P&gt;Eventually it gets to a Jinja2 template that does the core work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;clish_script_build.yml:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;...
...
- name: Generate CLISH script
  ansible.builtin.template:
    src: clish_cmd.j2
    dest: "files/{{ config_dir }}/{{ config_file }}"
    lstrip_blocks: true
  delegate_to: localhost
...
...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# cat templates/clish_cmd.j2 
{# VSX CLISH command #}

set virtual-system {{ hostvars[inventory_hostname]['vs_id'] }}
{{ clish_cmd }}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Send it over with put_file API:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;- name: Copy CLISH script
  check_point.gaia.cp_gaia_put_file:
    file_name: "/home/admin/{{ config_dir }}/{{ config_file }}"
    text_content: "{{ lookup('file', [ 'files', config_dir, config_file ] |join('/') ) }}\n"
    override: true
  delegate_to: "{{ vsx_host |default(inventory_hostname) }}"
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run it:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;- name: Apply CLISH script
  check_point.gaia.cp_gaia_run_script:
    description: 'CLISH script: {{ config_file }}'
    script: |
      clish -c 'lock database override'
      clish -c 'unlock database'
      clish -f /home/admin/{{ config_dir }}/{{ config_file }}
    wait_for_task: "{{ wait_for_api_task |default(true) }}"
  delegate_to: "{{ vsx_host }}"
  register: script_res
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Granted, I use and abuse put_file and run_script API to do the dirty work. &amp;nbsp;This helps (but does not eliminate) with the frustrating CLISH lock. &amp;nbsp;You also can run your playbook with 'admin' user if you want, and either do ansible-vault for the password, or prompt for it. &amp;nbsp;Or do other trickery.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I run this with a shell script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;./run_clish_command.sh -u admin_user_name -c 'show bgp peers' -l RTP_VS_1&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The shell script uses 'getopts' to parse the variables and send to the playbook. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# ./run_clish_command.sh -u admin_user_name -c 'show bgp peers' -l RTP_VS_1
Vault password: 

PLAY [Run CLISH command] *****************************************************************************************************************************

TASK [Run CLISH command on gateways] *****************************************************************************************************************
skipping: [RTP_VS_1]

TASK [Run CLISH command on VSX VS] *******************************************************************************************************************
included: /iac/playbooks/run_clish_command/vsx_clish_cmd.yml for RTP_VS_1

TASK [include_tasks] *********************************************************************************************************************************
included: /iac/playbooks/run_clish_command/clish_script_build.yml for RTP_VS_1 =&amp;gt; (item=usdc2-gw1: RTP_VS_1)
included: /iac/playbooks/run_clish_command/clish_script_build.yml for RTP_VS_1 =&amp;gt; (item=usdc2-gw2: RTP_VS_1)
included: /iac/playbooks/run_clish_command/clish_script_build.yml for RTP_VS_1 =&amp;gt; (item=usdc2-gw3: RTP_VS_1)

...
..
...

TASK [Copy CLISH script] *****************************************************************************************************************************
changed: [RTP_VS_1 -&amp;gt; usdc2-gw3(192.0.2.113)]

TASK [include_tasks] *********************************************************************************************************************************
included: /iac/playbooks/run_clish_command/clish_script_apply.yml for RTP_VS_1

TASK [Apply CLISH script] ****************************************************************************************************************************
changed: [RTP_VS_1 -&amp;gt; usdc2-gw3(192.0.2.113)]

TASK [Check for run-time errors] *********************************************************************************************************************
skipping: [RTP_VS_1]

TASK [Save output] ***********************************************************************************************************************************
included: /iac/playbooks/run_clish_command/save_output.yml for RTP_VS_1

TASK [Parse output] **********************************************************************************************************************************
ok: [RTP_VS_1]

TASK [Show command output] ***************************************************************************************************************************
ok: [RTP_VS_1] =&amp;gt; {
    "msg": [
        "Flags: R - Peer restarted, W - Waiting for End-Of-RIB from Peer",
        "",
        "PeerID           AS           Routes  ActRts  State             InUpds  OutUpds  Uptime  ",
        "100.64.0.2       64950        0       0       Idle              0       0        00:00:00  ",
        "100.64.0.3       64950        0       0       Idle              0       0        00:00:00  "
    ]
}

...
..
...


TASK [Copy CLISH script] *****************************************************************************************************************************
changed: [RTP_VS_1 -&amp;gt; usdc2-gw2(192.0.2.112)]

TASK [include_tasks] *********************************************************************************************************************************
included: /iac/playbooks/run_clish_command/clish_script_apply.yml for RTP_VS_1

TASK [Apply CLISH script] ****************************************************************************************************************************
changed: [RTP_VS_1 -&amp;gt; usdc2-gw2(192.0.2.112)]

TASK [Check for run-time errors] *********************************************************************************************************************
skipping: [RTP_VS_1]

TASK [Save output] ***********************************************************************************************************************************
included: /iac/playbooks/run_clish_command/save_output.yml for RTP_VS_1

TASK [Parse output] **********************************************************************************************************************************
ok: [RTP_VS_1]

TASK [Show command output] ***************************************************************************************************************************
ok: [RTP_VS_1] =&amp;gt; {
    "msg": [
        "Flags: R - Peer restarted, W - Waiting for End-Of-RIB from Peer",
        "",
        "PeerID           AS           Routes  ActRts  State             InUpds  OutUpds  Uptime  ",
        "100.64.0.2       64950        2399    2391    Established       7429    1        8w2d    ",
        "100.64.0.3       64950        2399    6       Established       7453    1        8w2d    "
    ]
}

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Anyhoo... yes, it's serial, because of the loop.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But, you can still run the Ansible host target against any VS, or all of them. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &amp;nbsp;You can also see that I have a companion (very similar) playbook to do this for non-VSX gateways. &amp;nbsp;Blast that all out in a playbook run, and I can pull "show bgp peers" for 150 different systems if I wanted.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps. &amp;nbsp;No I don't have this on a github, but I could be convinced...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 20:45:45 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/212338#M40300</guid>
      <dc:creator>Duane_Toler</dc:creator>
      <dc:date>2024-04-25T20:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: VSX, clish, and bash?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/216745#M41290</link>
      <description>&lt;P&gt;For the specific case of running a single command via clish (e.g, 'show ospf neighbors' during troubleshooting), I eventually arrived at this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#!/bin/env bash
clishScript=$(mktemp)
vsid="$1"
if [[ $vsid =~ '^[0-9]*$' ]];then shift;else vsid=0;fi
echo "set virtual-system ${vsid}" &amp;gt;${clishScript}
echo "$@" &amp;gt;&amp;gt;${clishScript}
clish -f "${clishScript}" | sed -E 's/^Processing .+?\r//g'
rm "${clishScript}"&lt;/LI-CODE&gt;
&lt;P&gt;You just put the VSID in as the first argument. If the first argument is non-numeric, it assumes VS 0. The rest can be quotes or not. The script handles creating a temp file, building the clish script, running it, suppressing the "Processing ..." output, and cleaning up the temp file after it's run.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[Expert@SomeVsxMember:0 STANDBY]# ./vsClish.sh show router-id
Context is set to vsid 0

Router ID:  10.16.32.64

Done.
[Expert@ SomeVsxMember:0 STANDBY]# ./vsClish.sh 0 show router-id
Context is set to vsid 0

Router ID:  10.16.32.64

Done.
[Expert@ SomeVsxMember:0 STANDBY]# ./vsClish.sh 2 show router-id
Context is set to vsid 2

Router ID:  10.20.40.80

Done.&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 14:56:08 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/VSX-clish-and-bash/m-p/216745#M41290</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2024-06-06T14:56:08Z</dc:date>
    </item>
  </channel>
</rss>

