Sponsored Content
Operating Systems Linux AIX 6.1 to Linux 7.2 migration Post 302986302 by Riverstone on Wednesday 23rd of November 2016 11:06:55 AM
Old 11-23-2016
Here is my first problem getting error as below while executing script.

OS version:
Linux VGP-3GPSDB-LX 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux

./imxtract.sh: line 395: unexpected EOF while looking for matching ``'
./imxtract.sh: line 402: syntax error: unexpected end of file

below is my script code , please assist to rectify the error.
Thanks in advance.


Code:
#!/bin/sh

. $HOME/.oraenv
. $HOME/.vifenv
CPDEVTSDEBUG="/tmp/CPDevts.debug"
CPDCSTADEBUG="/tmp/CPDcsta.debug"
CPDCSTFDEBUG="/tmp/CPDcstf.debug"
DATESTMP="`date '+%Y%m%d%H%M%S'`"
FILEDATE="`date '+%Y%m%d'`"
GPSTMP="/home/amp/tmp/"
WORKPATH="/tmp/"
CPDEVTSSEQ="CPDevts.seq"
CPDCSTASEQ="CPDcsta.seq"
CPDCSTFSEQ="CPDcstf.seq"
orasid="gpsu"
SQLLOGIN="`cat /home/amp/admin/sqlsec`"
pnum=1
pflag=0


# Funtion to display usage message #
#----------------------------------#
usagemsg ()
{
echo "Usage:"
echo "\tERROR!! No parameters are provided or parameters provided are incorrect."
echo ""
echo "\tValid parameters are as below:"
echo "\t\t./imxtract.sh -f {CPDevts|CPDcsta|CPDcstf} <month> <year>"
echo "\t\t./imxtract.sh -f {CPDcsta|CPDcstf} <day> <month> <year>\n"
echo "\t -f      = feed type"
echo "\t <day>   = day in 2 digits format. This parameter does not apply to feedtype 'CPDevtsf' & 'CPDevtsa'"
echo "\t <month> = month in 2 digits format"
echo "\t <year>  = year in 4 digits format"
}

# Function to check the validity of day value #
#---------------------------------------------#
chkday ()
{
 dy=$1
 mm=$2
 yy=$3
 if [ $dy -lt 1 ]; then
	usagemsg
	exit
 fi
 i=`echo $mm | wc -c`
 if [ $i -ne 3 ]; then
 	mm=`echo $mm | awk '{print "0"$1}'`
 fi
 case $mm in
 	01|03|05|07|08|10|12) dd=31
        ;;
	04|06|09|11) dd=30
        ;;
	02) if [ `expr $yy % 4` -eq 0 ]; then
	       	   dd=29
	    else
	       	   dd=28
	    fi
        ;;
 esac
 if [ $dy -gt $dd ]; then
	echo "Invalid day!!\n"
	usagemsg
	exit 
 fi
}


# Function to check the validity of month value #
#-----------------------------------------------#
chkmonth ()
{
 mth=$1
 if [ $mth -lt 1 ]; then
	usagemsg
	exit
 fi
 if [ $mth -gt 12 ]; then
	usagemsg
	exit
 fi
}

# Function to check the validity of year value #
#----------------------------------------------#
chkyear ()
{
 yr=$1
 if [ $yr -lt 1900 ]; then
	echo "Year value is less than 1900!!\n"
	usagemsg
	exit
 fi
 if [ $yr -gt 2999 ]; then
	echo "Year value is greater than 2999!!\n"
	usagemsg
	exit
 fi
}

# Function to extract data #
#--------------------------#
getdata ()
{
DATAPATH=$1
DEBUGFILE=$2
SEQFILE=$3
SQLCMD=$4
EFFDATE=$5
# Assigning sequence number #
#---------------------------#
if [ -f $DEBUGFILE ];  then
        rm $DEBUGFILE
fi
c=`ls $GPSTMP| grep -x $SEQFILE | wc -l`
if [ $c -eq 1 ]; then
        lastseqnum=`cat $GPSTMP$SEQFILE`
elif [ $c -gt 1 ]; then
        echo "More than 1 sequence file exists at $GPSTMP. Please check with the System Administrator."
        exit
elif [ $c -eq 0 ]; then
        lastseqnum=0
fi
seqnum=`expr $lastseqnum + 1`

echo $seqnum > $GPSTMP$SEQFILE
cnt=`echo $seqnum | wc -c`
if [ $cnt -lt 6 ]; then
        i=`expr 5 - $cnt`
        while [ $i -ne -1 ]
        do
           seqnum=`echo 0$seqnum`
           i=`expr $i - 1`
        done
elif [ $cnt -gt 6 ]; then
	echo "Sequence number to be assigned to file has exceeded 5 digits. Please check with Application Admin." | tee > $DEBUGFILE
	echo "To reset the reset the sequence number to zero(0), remove the $GPSTMP$SEQFILE" | tee >> $DEBUGFILE
	seqnum=`expr $seqnum - 1`
	echo $seqnum > $GPSTMP$SEQFILE
	exit
fi
if [ $EFFDATE -ne $FILEDATE ]; then
	TIMESTMP="`echo $DATESTMP | cut -c9-14`"
	HEADERDATE=$EFFDATE$TIMESTMP
else
	HEADERDATE=$DATESTMP
fi
WORKFILE="$DATAPATH""GPS_$FEED"_"$DATESTMP"_"$seqnum"_"$pnum.tmp"
sqlplus "$SQLLOGIN" $SQLCMD $WORKFILE > $DEBUGFILE

# Exception to handle non-existence of working file
ls $WORKFILE > /dev/null 2>&1
if [ $? -ne 0 ]; then
	seqnum=`expr $seqnum - 1`
	echo $seqnum > $GPSTMP$SEQFILE
	echo "$WORKFILE is not created. Please check..." | tee >> $DEBUGFILE
	exit
fi

# Exception to handle Oracle sql error
cat $DEBUGFILE | grep ORA- > /dev/null 2>&1
if [ $? -eq 0 ]; then
	rm -f $WORKFILE
	seqnum=`expr $seqnum - 1`
	echo $seqnum > $GPSTMP$SEQFILE
	echo "Oracle error is found in $DEBUGFILE. Please check..." | tee >> $DEBUGFILE
	exit
fi

# Create .dat file with header and trailer inserted #
#---------------------------------------------------#
DATAFILE="`echo $WORKFILE | sed 's/.tmp$/.DAT/g'"
header="00GPS    $FEED$HEADERDATE$seqnum$pnum$pflag"
echo "$header" > $DATAFILE
row="`tail -2 $WORKFILE | sed '/^$/d' | sed 's/rows selected//g' | sed 's/\.$//g' | cut -d' ' -f1`"
sed '$d' $WORKFILE | sed '$d' | sed '/^$/d' >> $DATAFILE   #To delete the last line and blank line
reccnt="`echo $row`"
if [ "$reccnt" = "no" ]; then
        row=00000000
else
        cnt="`echo $row | wc -c`"
        if [ $cnt -lt 9 ]; then
                i=`expr 8 - $cnt`
                while [ $i -ne -1 ]
                do
                   row="`echo 0$row`"
                   i=`expr $i - 1`
                done
        fi
fi

trailer="99GPS    $row"
echo "$trailer" >> $DATAFILE
rm $WORKFILE

# FTP .dat file to IM-CARGO SAS Server #
# ------------------------------------ #
FTPSFILE="`echo $DATAFILE | cut -d"/" -f6`"
#sh /home/amp/fisbin/imftp.sh $FTPSFILE $DATAPATH
}


############################################
# Main Body                                #
############################################
# Check the validity of parameters entered #
#------------------------------------------#
if [ $# -eq 0 ]; then
        usagemsg
        exit 
fi
if [ $1 = "-f" ] && [ $# -eq 1 ]; then
	usagemsg
	exit
fi 
if [ $1 != "-f" ]; then
	usagemsg
	exit
fi
if [ $2 != "CPDevts" ] && [ $2 != "CPDcsta" ] && [ $2 != "CPDcstf" ]; then
	usagemsg
	exit
fi
if [ $2 = "CPDevts" ] && [ $# -ne 4 ]; then
	usagemsg
	exit
fi
if [ $2 = "CPDcsta" ] && [ $# -ne 5 ]; then
	if [ $# -ne 4 ]; then
		usagemsg
		exit
	fi		
fi
if [ $2 = "CPDcstf" ] && [ $# -ne 5 ]; then
	if [ $# -ne 4 ]; then
		usagemsg
		exit
	fi
fi
if [ $2 = "CPDevts" ] && [ $# -eq 4 ]; then
         chkmonth $3
	 chkyear $4 
fi
if [ $2 = "CPDcsta" ] && [ $# -eq 4 ]; then
	chkmonth $3
	chkyear $4
fi
if [ $2 = "CPDcstf" ] && [ $# -eq 4 ]; then
	chkmonth $3
	chkyear $4
fi
if [ $2 = "CPDcsta" ] && [ $# -eq 5 ]; then
	chkday $3 $4 $5
	chkmonth $4
	chkyear $5
fi
if [ $2 = "CPDcstf" ] && [ $# -eq 5 ]; then
	chkday $3 $4 $5
	chkmonth $4
	chkyear $5
fi

FEED=`echo $2 | tr '[a-z]' '[A-Z]'`
case $FEED in
	CPDEVTS) mm=$3
		  yy=$4
		  i=`echo $mm | wc -c`
		  if [ $i -ne 3 ]; then
			mm=`echo $mm | awk '{print "0"$1}'`
		  fi 
		  case $mm in
			01|03|05|07|08|10|12) dd=31
			;;
			04|06|09|11) dd=30
			;;
			02) if [ `expr $yy % 4` -eq 0 ]; then
			      	dd=29
			    else
			     	dd=28
			    fi
			;;
	 	   esac
		   DATAPATH="/home/amp/fisoutput/FLT_EVENT/"
		   HEFFDATE=$yy$mm$dd
		   DEBUGFILE="$CPDEVTSDEBUG"
		   SEQFILE="$CPDEVTSSEQ"
		   SQL="@CPDevts.sql $mm $yy"
		   getdata $DATAPATH $DEBUGFILE $SEQFILE "$SQL" $HEFFDATE
	;;
	CPDCSTA|CPDCSTF) if [ $# -eq 5 ]; then
				dd=$3 
		  	   	mm=$4
		  	   	yy=$5
				dy=$dd
			   else
				dy=1
				mm=$3
				yy=$4
		  	        i=`echo $mm | wc -c`
		  	        if [ $i -ne 3 ]; then
				     mm=`echo $mm | awk '{print "0"$1}'`
		  	        fi
			   	case $mm in
				   01|03|05|07|08|10|12) dd=31
				   ;;
				   04|06|09|11) dd=30
				   ;;
				   02) if [ `expr $yy % 4` -eq 0 ]; then
			        	   dd=29
				       else
			        	   dd=28
				       fi
				   ;;
			   	esac
			   fi
			   case $mm in
				01) mon="JAN"
				;;
				02) mon="FEB"
				;;
				03) mon="MAR"
				;;
				04) mon="APR"
				;;
				05) mon="MAY"
				;;
				06) mon="JUN"
				;;
				07) mon="JUL"
				;;
				08) mon="AUG"
				;;
				09) mon="SEP"
				;;
				10) mon="OCT"
				;;
				11) mon="NOV"
				;;
				12) mon="DEC"
				;;
			   esac
			   while [ $dy -le $dd ]
			   do 
		  	      c=`echo $dy | wc -c`
		  	      if [ $c -ne 3 ]; then
		                 dy=`echo $dy | awk '{print "0"$1}'`
		  	      fi 
			      if [ $FEED = "CPDCSTA" ]; then
				 DATAPATH="/home/amp/fisoutput/SITA_PRI_MAS/"
		  		 DEBUGFILE="$CPDCSTADEBUG"
		  		 SEQFILE="$CPDCSTASEQ"
		  		 SQL="@CPDcsta.sql $dy-$mon-$yy $dy/$mm/$yy"
			      else
				 DATAPATH="/home/amp/fisoutput/SITA_PRI_MSK/"
		  		 DEBUGFILE="$CPDCSTFDEBUG"
		  		 SEQFILE="$CPDCSTFSEQ"
		  		 SQL="@CPDcstf.sql $dy-$mon-$yy $dy/$mm/$yy"
			      fi
			      HEFFDATE="$yy$mm$dy"
			      getdata $DATAPATH $DEBUGFILE $SEQFILE "$SQL" $HEFFDATE
			      dy=`expr $dy + 1`
			   done
	;;
esac
###################################################################
# End of Main Body                                                #
###################################################################

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

AIX Migration

Hi , Migrating AIX 4.3.3 ML10 to 5.3 ML1 (retaining 32 bit) after successfully going through 5 of the 5.3 Install CD's. After "All fileset's processed successfully " message I was told that system would reboot and then I would get prompted for setting TERm type ( i have an ascii ibm3151) and... (1 Reply)
Discussion started by: Student37
1 Replies

2. UNIX for Advanced & Expert Users

script migration from HP-UX to AIX

Dear All, What points should i keep in mind while migrating scripts from HP-UX to AIX. Are there any notes available for this? cheers, vishal (1 Reply)
Discussion started by: vishal_ranjan
1 Replies

3. AIX

AIX 5.2 to 5.3 migration

Hello All, We want to upgrade our 44p Model 270 from AIX 5.2 to 5.3. This is a standalone devlopment server but downtime is something we don't want because we have a short development deadline looming. I have no tape drive to make backups to. I myself am a developer and don't have any... (4 Replies)
Discussion started by: Fred Vogel
4 Replies

4. AIX

IY17981 fix required for aix 4.3.3 to aix 5L migration but not found

Hi, redbook documentation is telling that IY17981 fix is required for aix 4.3.3 to aix 5L migration. But there is no mention about that fix in any ML installation packages. - My system is ML11 : oslevel –r 4330-11 - But xlC.rte is on wrong version : lslpp -L xlC.rte xlC.rte ... (3 Replies)
Discussion started by: astjen
3 Replies

5. UNIX for Advanced & Expert Users

Migration of C Apps from AIX to LINUX

Hi All, I am currently facing new problem of migrating C(c language) application from AIX machine to Linux machine. We are using GCC to compile the source code.. But facing with the compilation issues, with lot of GCC C libs differing between AIX box to Linux box... Pls help me... (1 Reply)
Discussion started by: karthikc
1 Replies

6. Programming

Migration of C Apps from AIX to LINUX

Hi All, I am currently facing new problem of migrating C(c language) application from AIX machine to Linux machine. We are using GCC to compile the source code.. But facing with the compilation issues, with lot of GCC C libs differing between AIX box to Linux box... Pls help me... (1 Reply)
Discussion started by: karthikc
1 Replies

7. Red Hat

Print server Migration from AIX to Linux

Hi, Can anyone help me on migration the print server from AIX to RHEL 4? Appreciate your help? (1 Reply)
Discussion started by: brby07
1 Replies

8. Shell Programming and Scripting

AIX UNIX (kshell) to Linux Shell Script Migration.

Hi, Could you please let me know what kind of changes/issues commonly occurs at Scripting /command level during AIX Unix (kshell) to Linux shell script migration. (24 Replies)
Discussion started by: Raghuraman.R
24 Replies

9. AIX

AIX - FC Switch migration, SAN Migration question!

I'm New to AIX / VIOS We're doing a FC switch cutover on an ibm device, connected via SAN. How do I tell if one path to my remote disk is lost? (aix lvm) How do I tell when my link is down on my HBA port? Appreciate your help, very much! (4 Replies)
Discussion started by: BG_JrAdmin
4 Replies

10. Solaris

Migration from AIX to Solaris

We are going to work on a project which aims at migrating set of applications from AIX to Solaris. The major portion of the source code involves C, C++, Shell/PERL scripts and Oracle database. We are grateful hear about any commercial tools available for porting AIX to Solaris. Another... (2 Replies)
Discussion started by: Namitap
2 Replies
All times are GMT -4. The time now is 12:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy