All I needed to do was run isql <database name> MyQuery.sql from the unix command, ensuring that I am in the same path as the sql file. In the sql file is unload to /my/path/myFile.txt select * from MyTable;
Plus this does not need a shell script, I can simple call the .sql file from the cron tab using:
* * * * * * /usr/informix/bin/isql <myDatabaseName> /Path/to/myQuery.sql 2>&1
Main Topics
Browse All Topics





by: flutophilusPosted on 2009-10-21 at 12:04:53ID: 25627182
You need to set up the Informix environment variables in the shell script.
ation; export INFORMIXDIR nstallatio n; export PATH
It's the environment variables that are set by the script that runs when you log in that are used when you run isql from the command line directly. These are not copied over automatically to a shell script.
How and where the login script is run from will depend on your flavour of UNIX and the shell you are running. For example for Korn Shell on hp-ux the script will be /home/yourlogin/.profile (opbviously replace yourlogin by your actual login). Note that files beginning with a . are not normally shown when you list the directory. If you can find this script you can see what environment variables are set for Informix in your environment.
Another way to see what environment variables are set is to run the
set
command from the command prompt.
This shows all environmnt variables.
You'll need set these environment variabls in your shell script, which will look something like the following
INFORMIXSERVER = yourinstancename; export INFORMIXSERVER
you may also need
DBDATE = DMY4- ; export DBDATE
DCENTURY = C; export DBCENTURY
INFORMIXDIR = /pathtoyourinformixinstall
PATH = $PATH:/pathtoyourinformixi
Also a good idea to make the first line of any script something like
#!/usr/bin/ksh
(This will execute all the commands in the script under the korn shell - you'll probably need to change this to point to the shell you are actually using -have a look at the SHELL environment to see what that is.
You can also look at what environment variables are set by your login script by running
echo $environmentvariable from the command prompt
e.g
echo $INFORMIXSERVER
echo $SHELL
Note this is UNIX and CASE MATTERS
HTH