Results 1 to 12 of 12
  1. #1
    Join Date
    Feb 2004
    Posts
    16

    Unanswered: 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.

  2. #2
    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

  3. #3
    Join Date
    Feb 2004
    Location
    Tunisia
    Posts
    17
    Hi

    can you post the listing of the shell script ?

  4. #4
    Join Date
    Feb 2004
    Posts
    16
    Hi bull_abraham,

    You have solved my problem. Thanks a lot..

  5. #5
    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?

  6. #6
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    780
    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
    ..........
    ..........
    ..........

  7. #7
    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.

  8. #8
    Join Date
    Sep 2003
    Location
    Third rock from the sun
    Posts
    15
    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?

  9. #9
    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

    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?

  10. #10
    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

  11. #11
    Join Date
    Aug 2003
    Location
    India
    Posts
    262
    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

  12. #12
    Join Date
    Sep 2003
    Location
    Third rock from the sun
    Posts
    15
    Thanks Lloyd...

    My problem is solved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •