Link to home
Start Free TrialLog in
Avatar of Far22
Far22

asked on

get error in my shell script

Hi experts

in my shell script i have this line : dosql " update txout_820 set flag821 = 'H' where edifname= '04050055.23'"
i want to update my database.
when i run the script through cron i got this error message :-23101 Unable to load locale categories.
and i checked the database and it wasnt updated.

i couldnt find why dosql is not runnig and how to fix it ? what that error message is about?

when i comment dosql in my script , the error message didnt show up .

could you please help me with that? i appreciate any help. i need to fix this for my co-op job.

sorry if i post my question in wrong category.

thanks
Far22

this is my script:

#!/bin/sh
# This script will copy Bell Canada EDI file to AS2 server
############################

#####
export DBPATH=/swdbase/database
export DBTEMP=/swdbase/tmp
export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/informix/bin:/usr2/reporting/bin:/usr2/reporting/cvs-bprpt/script:/usr4/edi/edi_script
#####
THELOG=/usr2/logfile/edi_trans.log
BIN=/usr4/edi/edi_script
mm=` date +%m`
dd=` date +%d`
#viewfile=/usr4/edi/edi_as2_ready/vf

echo "------------------------------------------------------" >> $THELOG
echo "`date +%m/%d/%y-%H:%M:%S` : edi autosend.as2 starting -----" >> $THELOG
echo "  sending Bell Canada file to AS2 server " >> $THELOG
cd /usr4/edi/edi_as2_ready

echo $mm$dd

for edi_as2 in `ls`
do
       echo $edi_as2
                   echo " `date ` - starting duplicate check" >> $THELOG

        bellcdn=`$BIN/viewedi < $edi_as2 |grep 'BELLOACCTREC' |wc -l`

                        echo " size: $bellcdn "
        if (test $bellcdn -gt 0) then

                                                $BIN/autosend_edi_duplicate_check.pl $edi_as2 >> $THELOG
                                                result=$?

                                                case "$result" in
                                                            0)
                                                                  echo "$edi_as2 is NOT duplicated"
                                                                  scp $edi_as2 esp@172.17.68.216:/var/usr4/faran/scp_as2_file/ ### lexicom@clxp01as2.cucbc.com:/opt/lexicom/outbox/Bell/
                                                                  echo "The following file sent out:" >> $THELOG
                                                                  echo $edi_as2 >> $THELOG
                                                                  #mv $edi_as2 /usr4/edi/edi_backup/ > /dev/null 2>&1

                                                                  echo "update txout_820" >>$THELOG
                                                                  dosql " update txout_820 set flag821 = 'H' where edifname= '04050055.23'"      
                                                                  ;;
                                                            1)
                                                                  echo "$edi_as2 is duplicated"
                                                                  sendmon 1 " autosend.as2----$edi_as2 is duplicated,  Please check"
                                                ##### mv $edi_as2 $EDIDIR/edi_hold
                                                #####      cp $edi_as2 $EDIDIR/edi_hold            
                                                                  echo $edi_as2 "has been moved to edi_hold "
                                                                  echo "------------------------------------" >> $THELOG
                                                                  echo "update txout_820" >>$THELOG
                                                              dosql " update txout_820 set flag821 = 'N' where flag821 = 'C' and edifname = '$edi_as2' "
                                                                  ;;            
                                                            2)
                                                                  echo "not a 820 file"
                                                                  echo "not 820 file"  >> $THELOG

                                                #####       scp $edi_as2 esp@172.17.68.216:/var/usr4/faran/scp_as2_file/   ### lexicom@clxp01as2.cucbc.com:/opt/lexicom/outbox/Bell/

                                                ##### mv $edi_as2 /usr4/edi/edi_backup/ > /dev/null 2>&1
                                                #####      cp mv $edi_as2 /usr4/edi/edi_backup/ > /dev/null 2>&1            
                                                                  ;;
                                                            3)
                                                                  echo "no record found in database" ;;

                                          esac

                                          echo "result : $result"
                    else
           echo "No file to send." >> $THELOG
        fi
done  
echo "`date +%m/%d/%y-%H:%M:%S` : edi autosend.as2 ended -----" >> $THELOG
echo "------------------------------------------------------" >> $THELOG

exit 0

Avatar of Gabriel Orozco
Gabriel Orozco
Flag of Mexico image

this problem has happend with informix and scripts running from crontabs

may be you need to add at the top of your crontab:

. /etc/profile

so you can add all provile variables. But you may need only the locale variables:
http://www.iiug.org/forums/classics/index.cgi/read/1293
Avatar of Far22
Far22

ASKER

thanks for your response

i look at the link but i didnt get it what should i do to fix this.  i didnt understand the answer.sorry i'm new in that.

i understand this is a setting environment variable problem but i dont know how to fix this.
also, how can i add /etc/profile to the cron table?
i mean what is the syntax?
should i just put /etc/profile as the first line of the cron table? or should i put it before the line has my script?

is there a way i can fix it in my script instead of the cron table?

thanks a lot for your help.
Far22
sorry, change "crontab" for "script" instead:

may be you need to add at the top of your script:

. /etc/profile

but first be sure you have an /etc/profile =)
if it runs with your user, you might do something like
env
and have a look at your environment-settings (pretty close to what was mentioned above)
just export any environment-variable
e.g. if env displays a var like
SHELL=/bin/bash
then you can try
export SHELL=/bin/bash
and so on. Another possibility for you to use would be to trigger the command as the correct user.
this would be something like:
su - <username> -c /path/to/your/script
So cron would change to your UID and trigger the script with your environment...

hth,
Sumpi
ASKER CERTIFIED SOLUTION
Avatar of root_start
root_start
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Far22

ASKER

thanks a lot. it is working now.

i wish experts in bluethoot category were like you.

thanks a loooooooooooooooooooooooooot
Far22
Venabili: Please re-review the question as the user found an answer.

I think you would want to give the points to root_start perhaps
Did you read my message? Had I said that the solution is not found?
I think I overlooked your message. On other previous emails I got you were already given recommendation so I think it was because of that

my apologies =)
I give them when I am sure what to do. When I am not after the third reading, I just ask the experts to help me make the decision :)

It is ok :)

Venabili
Avatar of Far22

ASKER

hi experts

sorry i didnt check this email for a while for some reasons. i accepted the answer and it helped me to solve my problem.i thought it's clear from my last submission. thanks for your help again.