create a script

The difference between a script and a utility is that a utility just outputs set information via a template.

A script can used to perform actions on the instance, as well as get status information.

infx script

The infx script command is used to run your scripts. The command takes care of setting up the environment, manage log files etc, as well as executing your script

You can use this command to either create new scripts, or to re-use any of your existing scripts.

the script

For the purposes of this example, I will create a script that locates databases that are not logged, and turns their logging on.

First, I will use the infx status command to output information about the databases. Next, the script will se the infx backup command to turn logging on.

In real life, you would probably need to do a real backup soon after this.

We will use the infx status command in ad-hoc mode to output only the information we want.

shell script

For the infx script command to accept your script, it must meet the following guidelines.

  • Located in /infx/local/script
  • File owner is informix
  • Not be writable by others
  • File mode set to executable

I will use the infx status output to find the unlogged databases, then call the infx backup type=fake command to change logging mode.

Script will be called /infx/local/script/dblog.

That is all you need. The infx script command will take care of settings like PATH or INFORMIXDIR.

It will also record the output and status in the log file.

execute it

Pass the script name to the infx script command.

Now use the infx status command and check the status of each database.

options

Lets add an option to this script to choose between buffered and un-buffered logging.

To do this we will pass a parameter to the command, logmode=, to pass the type of logging mode we want to set.

Setting unbuffered logging

Setting buffered logging

parameters

You don’t need to parse the command line options in your script. The infx script command places the parameters into environment variables.

Environment variables are prefixed with INFX_, in our example the environment variable will be INFX_LOGMODE.

Yor scripts should provide default values, or produce error messages if something is missing.

Use the config.ini file to set or modify other environment variables you need for your scripts.