<?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: Obtaining VS info from Web API run-script route called on a Gateway in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200705#M8229</link>
    <description>&lt;P&gt;I have noticed that commands like mdsenv and vsenv do not work as such in bash scripts these days.&lt;/P&gt;
&lt;P&gt;Need to look into that.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Dec 2023 09:47:18 GMT</pubDate>
    <dc:creator>Hugo_vd_Kooij</dc:creator>
    <dc:date>2023-12-15T09:47:18Z</dc:date>
    <item>
      <title>Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200624#M8225</link>
      <description>&lt;P&gt;Hello everyone!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the management web API v1.9 and the run-script route targetted at a VSX gateway, I am able to run a command like "vsx stat -l" to get the stats of the virtual systems running on the gateway.&lt;/P&gt;&lt;P&gt;My problem is that when I try to run the command "vsenv [vsid]" with the run-script route, I get the error message "vsenv command not found". Why would that be ?&lt;/P&gt;&lt;P&gt;I am trying to move inside of a vs to then run the "ifconfig -a" via the web API and this seems to be the only path I have found yet until of&lt;SPAN&gt;ficial APIs for VSX are released as part of R82. I am using an API Key and an API User with elevated permission to authenticate with the API.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 15:24:48 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200624#M8225</guid>
      <dc:creator>ChadGPT</dc:creator>
      <dc:date>2023-12-14T15:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200645#M8228</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Could put-file in combination with run-script be an option?&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 18:48:20 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200645#M8228</guid>
      <dc:creator>Vincent_Bacher</dc:creator>
      <dc:date>2023-12-14T18:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200705#M8229</link>
      <description>&lt;P&gt;I have noticed that commands like mdsenv and vsenv do not work as such in bash scripts these days.&lt;/P&gt;
&lt;P&gt;Need to look into that.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 09:47:18 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200705#M8229</guid>
      <dc:creator>Hugo_vd_Kooij</dc:creator>
      <dc:date>2023-12-15T09:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200708#M8230</link>
      <description>&lt;P&gt;You need to sent the environment variables for the shell you are starting with run-script. this can be done by adding &lt;EM&gt;source /etc/bashrc ;&amp;nbsp;&lt;/EM&gt;before your command in the script value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[Expert@sc:0]# mgmt_cli -r true -f json run-script script-name "test" script "source /etc/bashrc ; vsenv" targets.1 "sc"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example, ignore the fail as I am executing the command on a Security Management Server&lt;/P&gt;
&lt;P&gt;[Expert@sc:0]# mgmt_cli -r true -f json run-script script-name "test" script "&lt;STRONG&gt;source /etc/bashrc ;&lt;/STRONG&gt; vsenv" targets.1 "sc" |&amp;nbsp;jq -r '.tasks[]."task-details"[].statusDescription'&lt;/P&gt;
&lt;P&gt;---------------------------------------------&lt;BR /&gt;Time: [10:24:48] 15/12/2023&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;"cpx-sc - test" failed (100%)&lt;BR /&gt;vsenv: This is only supported on a VSX machine.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 10:10:17 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200708#M8230</guid>
      <dc:creator>Jim_Oqvist</dc:creator>
      <dc:date>2023-12-15T10:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200752#M8234</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;&lt;P&gt;You seem to be using the mgmt_cli tool, I am using the Web Services. Looking at the documentation (&lt;A href="https://sc1.checkpoint.com/documents/latest/APIs/index.html?#web/run-script~v1.9%20" target="_blank"&gt;Check Point - Management API reference&lt;/A&gt;), it seems like I cannot add the source in the HTTP Request body...&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 16:44:32 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200752#M8234</guid>
      <dc:creator>ChadGPT</dc:creator>
      <dc:date>2023-12-15T16:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200754#M8235</link>
      <description>&lt;P&gt;Hi Vincent!&lt;/P&gt;&lt;P&gt;What difference would it make if I were to use put-file in combination with my run-script? I would pass the script in the put-file and then I would execute that script with run-script pointing at that script. I am not sure it would make a difference at the level where the command is executed ?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 16:48:09 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200754#M8235</guid>
      <dc:creator>ChadGPT</dc:creator>
      <dc:date>2023-12-15T16:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200755#M8236</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The mgmt_cli is just a client to send RESTful API requests as HTTP POST.&lt;/P&gt;
&lt;P&gt;This is how the payload looks like that is sent to the Server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Payload: {
             "script" : "source /etc/bashrc ; vsenv",
             "script-name":"test",
             "targets":["sc"]
         }&lt;/LI-CODE&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 17:27:15 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200755#M8236</guid>
      <dc:creator>Jim_Oqvist</dc:creator>
      <dc:date>2023-12-15T17:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200758#M8237</link>
      <description>&lt;P&gt;Thank you very much, this seems to do the trick !&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 18:12:08 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200758#M8237</guid>
      <dc:creator>ChadGPT</dc:creator>
      <dc:date>2023-12-15T18:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200925#M8243</link>
      <description>&lt;P&gt;If this can help anyone: I got it to work with "&lt;STRONG&gt;src /etc/bashrc ; vsenv [vsName] ;&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;/bin/cp-ifconfig.sh -a&lt;/STRONG&gt;"&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;ifconfig -a&lt;/STRONG&gt; gave the internal IP's.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;/bin/cp-ifconfig.sh&lt;/STRONG&gt; -a gives me the external IP's&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 16:20:55 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200925#M8243</guid>
      <dc:creator>ChadGPT</dc:creator>
      <dc:date>2023-12-18T16:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200962#M8244</link>
      <description>&lt;P&gt;All currently supported versions of VSX are based on Linux network namespaces rather than the old VRF extensions. As long as you're running a current version, the easiest way to run a command in a given VS is this:&lt;/P&gt;
&lt;P&gt;ip nets exec &amp;lt;namespace name&amp;gt; &amp;lt;command&amp;gt;&lt;/P&gt;
&lt;P&gt;The namespaces have predictable names in the form&amp;nbsp;&lt;SPAN&gt;CTX##### where ##### is the VSID padded out to five digits with leading zeroes. For example, VSID 4 is CTX00004 and VSID 196 is CTX00196.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For example, to run the command 'netstat -rn' in VSID 2, I use:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ip netns exec CTX00002 netstat -rn&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can get a list of all of the namespace names using 'ip nets list'. Note that this list includes switch contexts.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 18:41:28 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/200962#M8244</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2023-12-18T18:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining VS info from Web API run-script route called on a Gateway</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/201019#M8247</link>
      <description>&lt;P&gt;Useful information about the namespaces, thanks for sharing.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 08:56:36 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Obtaining-VS-info-from-Web-API-run-script-route-called-on-a/m-p/201019#M8247</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2023-12-19T08:56:36Z</dc:date>
    </item>
  </channel>
</rss>

