<?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: How to debug script execution in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18914#M1187</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What's the API/CLI call you're making to the script?&lt;/P&gt;&lt;P&gt;By that I mean the full call.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Nov 2018 05:31:20 GMT</pubDate>
    <dc:creator>PhoneBoy</dc:creator>
    <dc:date>2018-11-22T05:31:20Z</dc:date>
    <item>
      <title>How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18911#M1184</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 am trying to run my own script via mgmt_cli tool and I am getting the following output:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;statusCode: "failed"&lt;BR /&gt; statusDescription: "/tmp/rconfd-temp-script-iPZGST: line 1: Backup: command not found"&lt;BR /&gt; taskNotification: "97c04b63-33f7-4036-b2e0-fc18996077a2"&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, apparently there is something wrong (I am importing CP env btw) with the script execution and as far as I can see the tool creates some temp file (&lt;SPAN&gt;/tmp/rconfd-temp-script-iPZGST) that I suppose is exact copy of my script.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Problem is, that tempt script is automagically removed and I cannot inspect it. How to prevent that? Any command line option?&amp;nbsp;Is some pre-processing made before temp file is generated?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Nov 2018 12:07:16 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18911#M1184</guid>
      <dc:creator>HristoGrigorov</dc:creator>
      <dc:date>2018-11-21T12:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18912#M1185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Show us your script mate, so we'll be able to better understand what's happening.&lt;/P&gt;&lt;P&gt;Besides that you can easily run: &lt;SPAN style="color: #3366ff;"&gt;&lt;EM&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;while&lt;/SPAN&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;true; do cp /tmp/rconfd-temp* /home/admin; done; &amp;amp; &lt;/SPAN&gt;&lt;/CODE&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;in order to copy all temp files to your home dir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Nov 2018 14:22:11 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18912#M1185</guid>
      <dc:creator>Danny</dc:creator>
      <dc:date>2018-11-21T14:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18913#M1186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There you go. Nothing too serious. Works fine from command line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#!/bin/bash&lt;/P&gt;&lt;P&gt;###########################################################################&lt;/P&gt;&lt;P&gt;BACKUP_FILE=backup_CPSMS_`date +%d-%m-%y_%H%M`.tgz&lt;/P&gt;&lt;P&gt;BACKUP_PATH=/var/CPbackup/backups&lt;/P&gt;&lt;P&gt;BACKUP_COMMAND="/opt/CPsuite-R80.20/fw1/bin/upgrade_tools/migrate export -n"&lt;/P&gt;&lt;P&gt;BACKUP_SERVER='192.168.0.1'&lt;/P&gt;&lt;P&gt;BACKUP_USER='fwadmin'&lt;/P&gt;&lt;P&gt;BACKUP_PASS='********'&lt;/P&gt;&lt;P&gt;###########################################################################&lt;/P&gt;&lt;P&gt;echo `date +%d-%m-%yT%H%M` INFO: Backup script started&lt;/P&gt;&lt;P&gt;cd $BACKUP_PATH&lt;/P&gt;&lt;P&gt;source /etc/profile.d/CP.sh&lt;/P&gt;&lt;P&gt;# Run backup command&lt;BR /&gt;echo `date +%d-%m-%yT%H%M` "INFO: Running $BACKUP_COMMAND $BACKUP_FILE"&lt;BR /&gt;$BACKUP_COMMAND $BACKUP_FILE&lt;BR /&gt;if [ $? -ne 0 ]; then&lt;BR /&gt; echo `date +%d-%m-%yT%H%M` "FATAL: Backup command did not complete successfully"&lt;BR /&gt; exit 1&lt;BR /&gt;else&lt;BR /&gt; echo `date +%d-%m-%yT%H%M` "INFO: Backup command completed successfully"&lt;BR /&gt;fi&lt;/P&gt;&lt;P&gt;# Test backup file integrity&lt;BR /&gt;echo `date +%d-%m-%yT%H%M` "INFO: Testing archive integrity..."&lt;BR /&gt;/bin/tar -tzf $BACKUP_FILE &amp;gt; /dev/null&lt;BR /&gt;if [ $? -ne 0 ]; then&lt;BR /&gt; echo `date +%d-%m-%yT%H%M` "FATAL: Archive integrity test failed. Backup file is corrupt."&lt;BR /&gt; exit 1&lt;BR /&gt;else&lt;BR /&gt; echo `date +%d-%m-%yT%H%M` "INFO: Archive integrity test succeeded. Backup file is good."&lt;BR /&gt; echo `date +%d-%m-%yT%H%M` "INFO: Creating checksum file $BACKUP_FILE.MD5SUM"&lt;BR /&gt; /usr/bin/md5sum $BACKUP_FILE &amp;gt; $BACKUP_FILE.MD5SUM&lt;BR /&gt; echo `date +%d-%m-%yT%H%M` "INFO: Uploading archive to FTP server..."&lt;/P&gt;&lt;P&gt;ftp -n $BACKUP_SERVER &amp;lt;&amp;lt;END_SCRIPT&lt;BR /&gt;quote USER $BACKUP_USER&lt;BR /&gt;quote PASS $BACKUP_PASS&lt;BR /&gt;cd CPSMS&lt;BR /&gt;put $BACKUP_FILE.MD5SUM&lt;BR /&gt;binary&lt;BR /&gt;put $BACKUP_FILE&lt;BR /&gt;quit&lt;BR /&gt;END_SCRIPT&lt;/P&gt;&lt;P&gt;if [ $? -ne 0 ]; then&lt;BR /&gt; echo `date +%d-%m-%yT%H%M` "ERROR: FTP upload failed."&lt;BR /&gt; else&lt;BR /&gt; echo `date +%d-%m-%yT%H%M` "INFO: FTP upload completed."&lt;BR /&gt; fi&lt;/P&gt;&lt;P&gt;fi&lt;/P&gt;&lt;P&gt;echo `date +%d-%m-%yT%H%M` Removing backup file.&lt;BR /&gt;rm -f $BACKUP_FILE&lt;BR /&gt;rm -f $BACKUP_FILE.MD5SUM&lt;/P&gt;&lt;P&gt;echo `date +%d-%m-%yT%H%M` INFO: Backup script completed&lt;/P&gt;&lt;P&gt;# EOF&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Nov 2018 17:33:06 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18913#M1186</guid>
      <dc:creator>HristoGrigorov</dc:creator>
      <dc:date>2018-11-21T17:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18914#M1187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What's the API/CLI call you're making to the script?&lt;/P&gt;&lt;P&gt;By that I mean the full call.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2018 05:31:20 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18914#M1187</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2018-11-22T05:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18915#M1188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;mgmt_cli run-script script-name "Backup Export" script "Backup Export" targets CPSMS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2018 06:04:35 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18915#M1188</guid>
      <dc:creator>HristoGrigorov</dc:creator>
      <dc:date>2018-11-22T06:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18916#M1189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is literally what you're executing complete with literally script "Backup Export" as part of your CLI, that's probably why it's not working.&lt;/P&gt;&lt;P&gt;You should probably use put-file (or some other method) to copy the script to the appliance, then use run-script with the script argument calling the full path to the script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2018 06:26:07 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18916#M1189</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2018-11-22T06:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18917#M1190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to backup management server database not the appliance. And if I got it right, if a script is in management server repository it can run on any target with that command, no need to explicitly copy it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try Danny's suggestion today to&amp;nbsp;check what is that temp script looking and why it is not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the feeling the empty space in the script name ("Backup Export") is what is making it fail. Devs often forget to escape it &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, 22 Nov 2018 06:35:42 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18917#M1190</guid>
      <dc:creator>HristoGrigorov</dc:creator>
      <dc:date>2018-11-22T06:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18918#M1191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, two findings:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Devs do not escape spaces in script names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. I renamed script to BackupExport but that did not help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I managed to capture the temp script and it had only one line "BackupExport". Which does not make any sense.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, what am I doing wrong ?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2018 06:55:24 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18918#M1191</guid>
      <dc:creator>HristoGrigorov</dc:creator>
      <dc:date>2018-11-22T06:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18919#M1192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just that script via job scheduler?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2018 07:25:57 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18919#M1192</guid>
      <dc:creator>Martin_Valenta</dc:creator>
      <dc:date>2018-11-22T07:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug script execution</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18920#M1193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not recommended by CheckPoint, refer to &lt;A href="https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&amp;amp;solutionid=sk140852"&gt;sk140852&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But yes,&amp;nbsp;&lt;STRONG&gt;mgmt_cli&lt;/STRONG&gt; will end up in Job Scheduler once I made it to work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2018 08:01:23 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-debug-script-execution/m-p/18920#M1193</guid>
      <dc:creator>HristoGrigorov</dc:creator>
      <dc:date>2018-11-22T08:01:23Z</dc:date>
    </item>
  </channel>
</rss>

