Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script moved from HP-UX to AIX not working properly

Status
Not open for further replies.

rahill13

Technical User
May 30, 2002
6
US
I posted this once, and now I can't find it.
 
I suppose that you have something like

#!/usr/bin/ksh

as your first line? If you are defining your shell (sh, csh, ksh) there might be some other problem. But you have to tell us what your problem is. =)
 
This is a faily lengthly script. It moves a file from a mainframe to a Unix box, and updates an Oracle interface table. The data is pulled from the table by an oracle application job at a later time. The part of the script that is not working the the part that prevents duplicate entires from being in the interface table. We moved from HP-UX to AIX a few years ago, and I had to modify a lot of scripts, mostly just syntax. I don't know why I can't seem to get my hands around this. Here is some of the code.

# ***************************************************************
# copy the file from the staging area
echo " "
echo "Creating a new file: $MAINT_DB-$FILE_NAM.new"
echo "working...."
echo "working......"
cp $FROM_DIR/$FILE_NAM.001 $TO_DIR/$MAINT_DB-$FILE_NAM.tmp
STATUS=$?
if [ "$STATUS" != 0 ]
then
echo "The file copy from the Mainframe failed. Notify Tech Support." >> $MAINT_LOGS/$LOG_FL
echo "The file copy from the Mainframe failed. Notify Tech Support."
exit;
fi

fi;


# get header records
grep "*TOTAL*" $TO_DIR/$MAINT_DB-$FILE_NAM.tmp > gl_file.tmp1
COUNT_HD=`cat gl_file.tmp1 | cut -c3-9 | grep "*TOTAL*" | wc -l`
if [ "$COUNT_HD" = 0 ]
then
echo "The file copied from the Mainframe has no header record. Notify Tech Support." >> $MAINT_LOGS/$LOG_FL
echo "The file copied from the Mainframe has no header record. Notify Tech Support."
exit;
fi
DETAILS=`expr $TOT_NUM - $COUNT_HD`
# get detail records (all not *TOTAL*)
# grep -v "***TOTAL***" $TO_DIR/$MAINT_DB-$FILE_NAM.tmp > $TO_DIR/$MAINT_DB-$FILE_NAM.new

cp $TO_DIR/$MAINT_DB-$FILE_NAM.tmp $TO_DIR/$MAINT_DB-$FILE_NAM.new

TOT_REC=`wc -l < $TO_DIR/$MAINT_DB-$FILE_NAM.new`
echo &quot; &quot;
echo &quot;The GL data $COPY_MES to $TO_DIR as $MAINT_DB-$FILE_NAM.new.&quot;
echo &quot;$TOT_REC records are ready to be loaded to the gl_interface table.&quot;
# echo &quot;Do you want to proceed? y/n: &quot;\\c
# read yn rest_of_line
# case $yn in
# [Yy]) : ;;
# * ) exit 1;;
# esac

# ********************************************************************
# check for duplicate records already on the gl_interface table
# start a loop to get each header record
echo &quot;The following SOURCE and GROUP-ID sets were on the file.&quot; >> $MAINT_LOGS/$LOG_FL
echo &quot;SOURCE GROUP ID COUNT&quot; >> $MAINT_LOGS/$LOG_FL
i=1
j=$COUNT_HD
while [ &quot;$i&quot; -le $COUNT_HD ]
do

# get next header record
HEADER1=`head -n1 gl_file.tmp1 | cut -c1-10`
SOURCE1=`head -n1 gl_file.tmp1 | cut -c17-26`
GROUP1=`head -n1 gl_file.tmp1 | cut -c34-41`
COUNT1=`head -n1 gl_file.tmp1 | cut -c27-32`
check the gl_interface table to prevent reloading same data.
# delete all rows with matching source and group id
sqlplus gl/$USER_PW @$DHEC_SQL/dhgl_interface_delete.sql $SOURCE1 $GROUP1;

echo &quot;$SOURCE1 $GROUP1 $COUNT1&quot; >> $MAINT_LOGS/$LOG_FL
compute loop count
j=`expr $j - 1`
drop previous header record
tail -n$j gl_file.tmp1 > gl_file.tmp2
mv gl_file.tmp2 gl_file.tmp1
i=`expr $i + 1`
done
# **********************************************************************

**************dhgl_interface_delete.sql****************

rem delete rows from gl_interface table for existing value to prevent loading same data again.
rem source name and group id are passed from transfer script
rem set term off;
rem set echo off;
rem set heading off;
rem set feedback off;
delete from gl_interface
where user_je_source_name = '&1 &2' and group_id = '&3';
commit;
exit;

 
Is the problem that the records don't get deleted?

After a quick glance the script looks reasonable... have you verified that the column numbers for you 'cut' commands are correct? That is, do the lines getting written to the log file look right? And are these records actually deleted from the DB?
 
Not being someone who uses sqlplus, I am really just guessing, but I suspect that there might be some characters in your removal line that need escaping, or perhaps it might work to do a block quote. When in doubt, I block-quote. IBM Certified -- AIX 4.3 Administration
IBM Certified -- AIX 4.3 Support
IBM Certifiable!
 
The issue has been resolved. Two programmers made a change a few months back, and the problem didn't surface until we had a holiday.

GROUP1=`head -n1 gl_file.tmp1 | cut -c34-41`

NEEDED CHANGES

GROUP1=`head -n1 gl_file.tmp1 | cut -c33-43`

Thanks to all that replied.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top