<?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>Question Re: using hdbsql in shell script and query database in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaa-p/14233867#M4928197</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;I was able to reproduce the issue on a local test system.&lt;BR /&gt;I got around it by simplifying the hdbsql command as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HDBBACKUPTEST=$(sudo su - "$HDBSIDADM" -c 'hdbsql -U HDBUSERSTOREKEY " select * from "SYS"."M_BACKUP_CATALOG" " ' )&lt;BR /&gt;&lt;BR /&gt;In the example above I took out the ";" which I assumed was causing the command to get broken.&amp;nbsp; I see that the original command was trying to use \c and ; for multiline mode, but I'm not sure that you need that.&lt;BR /&gt;&lt;BR /&gt;If you need to embed a more complex hdbsql command, I'd suggest embedding the command into its own environment variable using a heredoc, similar to this:&lt;BR /&gt;&lt;BR /&gt;HDBSQL_CMD=$(cat &amp;lt;&amp;lt;'EOSQL'&lt;BR /&gt;hdbsql -U HDBUSERSTOREKEY "select \* from \"SYS\".\"M_BACKUP_CATALOG\""&lt;BR /&gt;EOSQL&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;That may help you avoid issues with the quoting later on.&lt;BR /&gt;&lt;BR /&gt;I hope this helps,&lt;BR /&gt;Kind regards,&lt;BR /&gt;Dan&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Oct 2025 02:59:54 GMT</pubDate>
    <dc:creator>Dan_Cummins</dc:creator>
    <dc:date>2025-10-03T02:59:54Z</dc:date>
    <item>
      <title>using hdbsql in shell script and query database</title>
      <link>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaq-p/14232273</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;i want to use hdbsql in a shell script, to run a query for checking database backups. Unfortunately i am only able to login with hdbuserstorekey in my script after that the select statement does not work (select "command not found")&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;SAPSTRING=$(find /usr/sap/ccms -maxdepth 2 -type d -name sapccmsr | head -n 1 | cut -c 15-17)
HDBSTRING=$(/usr/bin/cat /usr/sap/"$SAPSTRING"/SYS/profile/DEFAULT.PFL | grep dbs/hdb/dbname | awk {' print$3'})
echo "HDB System ID ----------&amp;gt; " $HDBSTRING
declare -l HDBSIDADM
HDBSIDADM=$HDBSTRING'adm'

HDBBACKUPTEST=$(sudo su - "$HDBSIDADM" -c 'hdbsql -c ";" "\c -U HDBUSERSTOREKEY ";" select * from "SYS"."M_BACKUP_CATALOG" " ' )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this results in&lt;/P&gt;&lt;P&gt;-bash: select * from SYS.M_BACKUP_CATALOG : command not found&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;seems like that after the successful connect with hdbuserstorekey, it closes the connection and so the select command is not known.&lt;/P&gt;&lt;P&gt;any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Oct 2025 06:47:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaq-p/14232273</guid>
      <dc:creator>qwertie</dc:creator>
      <dc:date>2025-10-01T06:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: using hdbsql in shell script and query database</title>
      <link>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaa-p/14233866#M4928196</link>
      <description>Hello,</description>
      <pubDate>Fri, 03 Oct 2025 02:54:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaa-p/14233866#M4928196</guid>
      <dc:creator>Dan_Cummins</dc:creator>
      <dc:date>2025-10-03T02:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: using hdbsql in shell script and query database</title>
      <link>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaa-p/14233867#M4928197</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I was able to reproduce the issue on a local test system.&lt;BR /&gt;I got around it by simplifying the hdbsql command as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HDBBACKUPTEST=$(sudo su - "$HDBSIDADM" -c 'hdbsql -U HDBUSERSTOREKEY " select * from "SYS"."M_BACKUP_CATALOG" " ' )&lt;BR /&gt;&lt;BR /&gt;In the example above I took out the ";" which I assumed was causing the command to get broken.&amp;nbsp; I see that the original command was trying to use \c and ; for multiline mode, but I'm not sure that you need that.&lt;BR /&gt;&lt;BR /&gt;If you need to embed a more complex hdbsql command, I'd suggest embedding the command into its own environment variable using a heredoc, similar to this:&lt;BR /&gt;&lt;BR /&gt;HDBSQL_CMD=$(cat &amp;lt;&amp;lt;'EOSQL'&lt;BR /&gt;hdbsql -U HDBUSERSTOREKEY "select \* from \"SYS\".\"M_BACKUP_CATALOG\""&lt;BR /&gt;EOSQL&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;That may help you avoid issues with the quoting later on.&lt;BR /&gt;&lt;BR /&gt;I hope this helps,&lt;BR /&gt;Kind regards,&lt;BR /&gt;Dan&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2025 02:59:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaa-p/14233867#M4928197</guid>
      <dc:creator>Dan_Cummins</dc:creator>
      <dc:date>2025-10-03T02:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: using hdbsql in shell script and query database</title>
      <link>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaa-p/14233875#M4928201</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/7496"&gt;@qwertie&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;In the past, I encountered similar errors. I resolved them by placing the hdbsql commands in a file and then calling it from the shell script.&lt;BR /&gt;I suggest you try this approach.&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Charles&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2025 03:05:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaa-p/14233875#M4928201</guid>
      <dc:creator>CharlesFeng</dc:creator>
      <dc:date>2025-10-03T03:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: using hdbsql in shell script and query database</title>
      <link>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaa-p/14235691#M4928419</link>
      <description>&lt;P&gt;Hello Dan,&lt;/P&gt;&lt;P&gt;thank you very much for clarification. It did the trick and script is working now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;qwertie&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 11:48:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-hdbsql-in-shell-script-and-query-database/qaa-p/14235691#M4928419</guid>
      <dc:creator>qwertie</dc:creator>
      <dc:date>2025-10-06T11:48:46Z</dc:date>
    </item>
  </channel>
</rss>

