How to Query an Informix Database Remotely via Shell Script

In this guide, we will walk through the steps for querying an Informix database remotely via shell script. As a developer, you may want to use a shell script to query an Informix database, especially if you require multiple users to access the database simultaneously. You may also want to automate certain processes by writing a shell script or creating a cron job that regularly performs certain queries. Here, you will learn the basics of creating and running a shell script that can query an Informix database remotely.

What You will Learn

In this guide, you will learn:

  • What an Informix database is.
  • How to setup access to the Informix database via a shell script.
  • How to write an SQL query in the shell script.
  • How to run the shell script.


Before proceeding with this tutorial, ensure that you have the following prerequisites in place:

  • Access to an Informix database.
  • An SSH terminal.
  • A working shell script editor.

Connecting to the Informix Database

To get started, you first need to connect to the Informix database. To do this, you will use an SSH terminal. Depending on the shell script editor you are using, there should be an option to connect to a remote server. If not, there are other command-line tools that can be used.

Once you are connected to the server, you will need to determine the database's hostname, port, username, and password. These details should be provided by your database administrator. Once you have this information, you can enter it into the terminal and login to the database.

Writing the SQL Query

Once you are connected to the database, you will need to enter the SQL query that you want to run. This is the same as any other SQL query, but will be run within the shell script. The SQL query should be written in the same format as it would be typed in any other SQL query tool.

For example, if you wanted to select all data from a table called “users”, the query would look like this:

SELECT * FROM users;

Running the Shell Script

Once your SQL query is written, you can save the shell script and run it. Depending on the editor you are using, this process will vary. In most cases, you can run the script by typing “sh” into the terminal. This will execute the script and run the SQL query.


What is an Informix database?

An Informix database is a commercial database server developed by IBM. It is geared towards applications that require high transactional throughput, such as ERP and e-commerce applications.

How do I connect to an Informix database?

You can connect to an Informix database using a SSH terminal. You will need to know the hostname, port, username, and password for the database in order to access it.

What language is used for writing SQL queries?

SQL queries are written in SQL. This is the same language that is used by most database servers, and is relatively easy to learn.

What is a shell script editor?

A shell script editor is an application that allows you to edit and create shell scripts. Some popular shell script editors include Vim, Emacs, and vi.

How do I run a shell script?

You can run a shell script by typing “sh” into the terminal. This will launch the script and execute its commands.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.