If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > informix and aix script

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-10-09, 13:38
sobnc sobnc is offline
Registered User
 
Join Date: Dec 2009
Posts: 16
Post informix and aix script

Dear sir
I am trying to implement a daily task that would permit me to extract by dbaccess in my informix database a records from several remote aix server and a script .sh would copy results from the remote to my server. All this have to be executed daily by a crontab in my aix server. When I am testing the scripts all is okay buy at the time that crontab has to execute the script i have in my error log file a message "/home/ope_for.sh: dbaccess: not found".
note: /home is the path where the script .sh is located, ope_for is my script
my script contain this line: dbaccess base ope_for_new (where my base is my database, and ope_for_new is my sql query)

How to resolve this issue?
Reply With Quote
  #2 (permalink)  
Old 12-10-09, 18:11
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
If the script is initiated by the crontab of an Informix user (with the appropriate rights and settings) you forgot to set the Informix environment variables explicitly in the script. A crontab job is namely started without the environment variables that are common for a loginshell of the user.

Regards,
Hans
Reply With Quote
  #3 (permalink)  
Old 12-11-09, 06:02
sobnc sobnc is offline
Registered User
 
Join Date: Dec 2009
Posts: 16
Post crontab environment

Dear Sir
I pleased you to tell me which are crontab variables environment to be set up in my script so that i have right result.
This is my crontab:
30 16 * * * /home/ope_for.sh "everyday at 4'30mn the crontab launch the script ope_for.sh which it self launch dbaccess my_database and execute the query ope_for_new
Thanks
Reply With Quote
  #4 (permalink)  
Old 12-11-09, 10:14
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
The envvars have nothing to do with crontab but everythingh with the Informix environment. Check out which way a loginshell of the user for whom crontab is configured receives it's Informix envvars upon initiation. Usually it's done somewhere in the .profile or somewhere else in the shell init procedure by sourcing another scriptfile with a line like this
Code:
. /opt/informix/../..
The sourcefile can have any name so check out every file that's sourced with the dot operator at the beginning of the line.

It's also possible that the variables are set manually in the .profile itself. In any case the INFORMIXDIR, INFORMIXSERVER and ONCONFIG variables should be set.

Regards,
Hans
Reply With Quote
  #5 (permalink)  
Old 12-12-09, 07:46
sobnc sobnc is offline
Registered User
 
Join Date: Dec 2009
Posts: 16
next step2

Dear Sir
I am little confuse about the location of the envvars on informix in .profile. Please i want to know where and how to set these informix environment INFORMIXDIR, INFORMIXSERVER and ONCONFIG. Look this syntax
INFORMIXDIR=/informix
INFORMIXSERVER= the_name_of_server
ONCONFIG ????
thanks
Reply With Quote
  #6 (permalink)  
Old 12-13-09, 04:48
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Set in the script that's run by crontab the necessary variables for connecting with the Informix engine. In my situation these variables are set in a file that's sourced into the .profile of Informix users and also into the DB scripts run by crontabs. For our IDS 10.00.UC6E these variables are:
Code:
export INFORMIXDIR="..."                      
export PATH="${PATH}:${INFORMIXDIR}/bin"                           
export ONCONFIG="onconfig.$(hostname)"                            
export INFORMIXTERM="terminfo"                                     
export INFORMIXSERVER="..."                                
export LD_LIBRARY_PATH="${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql"
export DBDATE=DMY4-                                                
export DBEDIT=vim
You can check the settings of these variables on your own system by performing
Code:
set | grep variablename
on the commandline of an Informix user shell.

Regards,
Hans
Reply With Quote
  #7 (permalink)  
Old 12-15-09, 03:44
sobnc sobnc is offline
Registered User
 
Join Date: Dec 2009
Posts: 16
Post step 3

Dear sir
I just try to set up envionment variables as follow
export INFORMIXDIR=/home/informix
export INFORMIXSERVER=server_live
export DBDATE=dmy4/
export DBEDIT=vi
dbaccess server_live ope_for
but i am still having an error message in the error log file
/home/ope_for.sh[5]: dbaccess: not found.
The fact i am not understanding is that when I launch the the script on command line i have no problem but i want the system to do it because I need to do it a dozen every 6 hours.
Thanks for your contribution
Reply With Quote
  #8 (permalink)  
Old 12-15-09, 07:11
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
That's what I said: when a shell is started through crontab the regular environment variables aren't loaded so you have tot do that manually.
Try to find the location of the dbaccess program with:
Code:
$ which dbaccess
This should be in $INFORMIXDIR/bin. The $INFORMIXDIR value is decided during server installation and is usually NOT /home/informix! Check the environment of your interactive shell!!!
Then append this directory to the PATH variable with:
Code:
export PATH="${PATH}:${INFORMIXDIR}/bin"
Write this in the script that's executed by crontab.

Regards

Last edited by Tyveleyn; 12-15-09 at 07:22.
Reply With Quote
  #9 (permalink)  
Old 12-15-09, 08:04
sobnc sobnc is offline
Registered User
 
Join Date: Dec 2009
Posts: 16
Dear sir
I correct the script contain by providing the export PATH and now i have this error message:
329: Database not found or no system permission.

20: Not a directory
Reply With Quote
  #10 (permalink)  
Old 12-24-09, 17:13
sobnc sobnc is offline
Registered User
 
Join Date: Dec 2009
Posts: 16
merry christmas

Hi Tyveleyn
I am still have problem to execute my query inside a crontab even after setting environment variable. Now the error message is
329: Database not found or no system permission.

20: Not a directory

Thanks
Reply With Quote
  #11 (permalink)  
Old 01-06-10, 07:50
theeiledon theeiledon is offline
Registered User
 
Join Date: Nov 2004
Posts: 60
It looks like you are trying to connect to a database that either locally is not known, or remotely does not have permissions for your user.

Locally you must define the remote hostname in DNS (or the local /etc/hosts file) and also the remote instance in the sqlhosts file. Test this by trying to connect to the remote instance using dbaccess.

Remotely the username you are connecting as must exist, and be trusted in the database with connect, select etc. permissions.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On