I want to manage DB2 database on remote host executing bash script on local host.
#!/bin/bash
host="80.80.80.80"
user="db2inst1"
DBname=DBNAME
db2="/opt/db2/db2inst1/sqllib/bin/db2"
ssh -t $host bash -c "'
sudo -u $user $db2 connect to $DBname
sudo -u $user $db2 quiesce database immediate force connections
'"
I connect to the host and connect to the database. But it seems, that connection to DB resets after first command and I get next error:
Database Connection Information
Database server = DB2/LINUXX8664 9.7.7
SQL authorization ID = DB2INST1
Local database alias = DBNAME
SQL1024N **A database connection does not exist**. SQLSTATE=08003
Connection to 80.80.80.80 closed.
How to keep the connection to a DB permanently on?