# How to connect to database db2 through Unix Shell Script

**URL:** <https://community.unix.com/t/how-to-connect-to-database-db2-through-unix-shell-script/166431>\
**Category:** Shell Programming and Scripting\
**Created:** [October 30, 2006, 1:47am UTC](https://community.unix.com/t/how-to-connect-to-database-db2-through-unix-shell-script/166431 "2006-10-30T01:47:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankitgupta](https://community.unix.com/letter_avatar/ankitgupta/32/5_5575768a8748004e209b776fc1b2916d.png) [@ankitgupta](https://community.unix.com/u/ankitgupta)\
**Post date:** [October 30, 2006, 1:47am UTC](https://community.unix.com/t/how-to-connect-to-database-db2-through-unix-shell-script/166431/1 "2006-10-30T01:47:04Z")

</div>

I am trying to connect to database db2 through shell script.

The process I am trying is

\> db2  
It gives me error Access Denied.  
While checking for access I have the rights.

Is there ant other way round..?  
Please help.

---

<div class="post-metadata">

**Author:** ![jambesh](https://community.unix.com/user_avatar/community.unix.com/jambesh/32/421_2.png) [@jambesh](https://community.unix.com/u/jambesh)\
**Post date:** [October 30, 2006, 2:35am UTC](https://community.unix.com/t/how-to-connect-to-database-db2-through-unix-shell-script/166431/2 "2006-10-30T02:35:37Z")

</div>

db2 connect to dbname user uname using pword

dbname: database name  
uname : user name  
pword : password

db2 +c -tv "SQL COMMAND"

---

<div class="post-metadata">

**Author:** ![ankitgupta](https://community.unix.com/letter_avatar/ankitgupta/32/5_5575768a8748004e209b776fc1b2916d.png) [@ankitgupta](https://community.unix.com/u/ankitgupta)\
**Post date:** [October 31, 2006, 5:25am UTC](https://community.unix.com/t/how-to-connect-to-database-db2-through-unix-shell-script/166431/3 "2006-10-31T05:25:38Z")

</div>

can u please elaborate as the same problem persists..

---

<div class="post-metadata">

**Author:** ![jambesh](https://community.unix.com/user_avatar/community.unix.com/jambesh/32/421_2.png) [@jambesh](https://community.unix.com/u/jambesh)\
**Post date:** [October 31, 2006, 8:50am UTC](https://community.unix.com/t/how-to-connect-to-database-db2-through-unix-shell-script/166431/4 "2006-10-31T08:50:10Z")

</div>

what you checked to know you have permission ??  
make sure from where you are executing the command is in the path or else look where db2 executable is ? if it would run it should ask user id and password  
means db2 command is not executing please use the find command to look for db2  
and then try.  
i won't have any problem executing db2 from my unix machine.
