Connecting to DB2 database on Mainframe and Querying DB

I am trying to develop a script that can connect to a DB2 database mainframe and Query the database and display the results. I've been researching, but I have yet to find a definitive solution where I can enter in the Mainframe DB2 address db2:// and query the database and return the results. If anyone has any information that can help me it will be greatly appreciated. Thanks All.

i) code something using a framework like e.g. Perl DBI or Java JDBC
ii) Does it have to be a standalone script? Install the free DB2 kit on some machine and copy'n'paste in some queries.

Connecting from Unix to z/OS is not free. You need a license for this.

You need to install and configure DB2 client to do that. Once you have DB2 installed on your UNIX box you will need to catalog the z/OS system and database if you run DB2 Connect locally. If you don't run DB2 Connect locally then you will need to catalog the node to point to the DB2 Connect server.

The script does not point to the server directly

here is a simple example

#!/bin/ksh

db2 connect to yourdb
db2 "select * from your blah.table"
db2 terminate