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 > Why scheduled cron job cannot execute dbaccess?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-04, 10:37
tanboonhoe tanboonhoe is offline
Registered User
 
Join Date: Feb 2004
Posts: 16
Why scheduled cron job cannot execute dbaccess?

I have a small shell script program which need to access a table in informix database. Therefore I inserted a dbaccess (some simple select statement) command in the program. Whenever I execute the program from unix command prompt. it manage to access the table and retrieve the value I wanted.

However when I configure the program to run a cron job, it failed to retrieve the value and just quit. I'm not sure why it is behaving like this. FYI, I have granted my login user to RESOURCE rights. I would appreciate if you can assist me. Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 03-03-04, 10:42
bull_abraham bull_abraham is offline
Registered User
 
Join Date: Feb 2004
Posts: 32
setup the environment variables in the script. When cron is executed, it needs the environment setup for the shell it spawns. Since you have your env setup while you execute in the command line, it runs fine.
the first few line of the script could be something like this....
#!/bin/ksh
<home-directory of the user>/.profile

script body.

-Abraham
Reply With Quote
  #3 (permalink)  
Old 03-03-04, 10:43
Aroui Aroui is offline
Registered User
 
Join Date: Feb 2004
Location: Tunisia
Posts: 17
Hi

can you post the listing of the shell script ?
Reply With Quote
  #4 (permalink)  
Old 03-05-04, 02:25
tanboonhoe tanboonhoe is offline
Registered User
 
Join Date: Feb 2004
Posts: 16
Hi bull_abraham,

You have solved my problem. Thanks a lot..
Reply With Quote
  #5 (permalink)  
Old 03-23-04, 04:59
Audra Audra is offline
Registered User
 
Join Date: Sep 2003
Location: Third rock from the sun
Posts: 15
Tanboonhoe,

Can you please show me how to do this? I'm kinda stuck.. I have a shell script which has the dbaccess command. And based on the reply above, I've put the .profile line into the shell script.

How to go from there?
Reply With Quote
  #6 (permalink)  
Old 03-23-04, 07:27
gurey gurey is offline
Registered User
 
Join Date: Aug 2003
Location: Argentina
Posts: 780
Quote:
Originally posted by Audra
Tanboonhoe,

Can you please show me how to do this? I'm kinda stuck.. I have a shell script which has the dbaccess command. And based on the reply above, I've put the .profile line into the shell script.

How to go from there?
Hi,

Please test follow

#!/bin/ksh

INFORMIXDIR=...... ; export INFORMIXDIR
INFORMIXSERVER=.....; export INFORMIXSERVER
ONCONFIG=.......: export ONCONFIG
PATH=$INFORMIXDIR/bin:$PATH ; export PATH
..........
..........
..........
Reply With Quote
  #7 (permalink)  
Old 03-23-04, 21:18
tanboonhoe tanboonhoe is offline
Registered User
 
Join Date: Feb 2004
Posts: 16
Well, I tried to put .profile at the calling program and it didn't work out. So alternately I add the informix environment at the beginning of the program and it just worked. You can add the lines as suggested by Gurey. Hope you find it useful.
Reply With Quote
  #8 (permalink)  
Old 03-24-04, 04:27
Audra Audra is offline
Registered User
 
Join Date: Sep 2003
Location: Third rock from the sun
Posts: 15
Quote:
Originally posted by gurey
Hi,

Please test follow

#!/bin/ksh

INFORMIXDIR=...... ; export INFORMIXDIR
INFORMIXSERVER=.....; export INFORMIXSERVER
ONCONFIG=.......: export ONCONFIG
PATH=$INFORMIXDIR/bin:$PATH ; export PATH
..........
..........
..........
Hi there,

I modified my script and put all the above and I received a message stating "dbaccess not found".

Why is that and how to solve this? I'm really out of ideas. Could be something that I missed?
Reply With Quote
  #9 (permalink)  
Old 03-24-04, 06:20
lloydnwo lloydnwo is offline
Registered User
 
Join Date: Aug 2003
Location: India
Posts: 262
Hi Audra,

Can you post your script.
Also try to include this entry in your script
INFORMIXSQLHOSTS=........
export INFORMIXSQLHOSTS

Regards,

Lloyd

Quote:
Originally posted by Audra
Hi there,

I modified my script and put all the above and I received a message stating "dbaccess not found".

Why is that and how to solve this? I'm really out of ideas. Could be something that I missed?
Reply With Quote
  #10 (permalink)  
Old 03-24-04, 21:20
Audra Audra is offline
Registered User
 
Join Date: Sep 2003
Location: Third rock from the sun
Posts: 15
#!/bin/ksh
INFORMIXDIR=/maindir/informix; export INFORMIXDIR
INFORMIXSERVER=ifmxsvr1; export INFORMIXSERVER
ONCONFIG=onconfig.dev; export ONCONFIG
PATH=#INFORMIXDIR/bin:$PATH; export PATH

dbaccess sampledb test.sql
Reply With Quote
  #11 (permalink)  
Old 03-24-04, 22:10
lloydnwo lloydnwo is offline
Registered User
 
Join Date: Aug 2003
Location: India
Posts: 262
Quote:
Originally posted by Audra
#!/bin/ksh
INFORMIXDIR=/maindir/informix; export INFORMIXDIR
INFORMIXSERVER=ifmxsvr1; export INFORMIXSERVER
ONCONFIG=onconfig.dev; export ONCONFIG
PATH=#INFORMIXDIR/bin:$PATH; export PATH

dbaccess sampledb test.sql
Hi Audra,

The PATH variable should be

PATH=$INFORMIXDIR/bin:$PATH; export PATH

Also include an entry for INFORMIXSQLHOSTS, this should point to your sqlhosts file

Eg.
INFORMIXSQLHOSTS=/export/home/informix/etc/sqlhosts2;
export INFORMIXSQLHOSTS;

Regards,

Lloyd
Reply With Quote
  #12 (permalink)  
Old 03-24-04, 23:01
Audra Audra is offline
Registered User
 
Join Date: Sep 2003
Location: Third rock from the sun
Posts: 15
Thanks Lloyd...

My problem is solved.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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