Topic
  • 1 reply
  • Latest Post - ‏2019-03-26T09:06:57Z by Nagaraju Polaveni
memet_tiike
memet_tiike
21 Posts

Pinned topic Command Substitution problem for DSWC executable shell scripts

‏2014-12-03T12:11:18Z |

Hi,

We are using DB2 LUW 10.1 on RHEL 6 and DSWC V4.1.1 on Linux.

I have a sample shell script as follows:

db2 connect to MYDEVLDB
MYVAR=$(db2 -x "select 'MYVAR7' from sysibm.sysdummy1")
db2 connect reset
db2 terminate
echo "$MYVAR"

 when I run this script as an sh script on the server I get the following:


   Database Connection Information

 Database server        = DB2/LINUXX8664 10.1.3
 SQL authorization ID   = DB2INST1
 Local database alias   = MYDEVLDB

DB20000I  The SQL command completed successfully.
DB20000I  The TERMINATE command completed successfully.
MYVAR7

 

However, when I run the same script from IBM DSWC as an Executable Shell Script job, I get the following:

 

 
Database Connection Information

 Database server        = DB2/LINUXX8664 10.1.3
 SQL authorization ID   = DB2INST1
 Local database alias   = MYDEVLDB

DB20000I  The SQL command completed successfully.
DB20000I  The TERMINATE command completed successfully.
SQL1024N  A database connection does not exist.  SQLSTATE=08003

So, why does not "command substitution" ($(command) or using backstick) does not work with DSWC?

Any help appreciated. Thanks.

  • Nagaraju Polaveni
    Nagaraju Polaveni
    1 Post

    Re: Command Substitution problem for DSWC executable shell scripts

    ‏2019-03-26T09:06:57Z  

    Hi Memet, Did you find a solution for this issue? Just curious on how this issue was resolved.