Hi,
recently we have migrated our current AIX server to Linux, we have lot of shell script, few of them are FTP scripts.
we have copied the complete AIX file system to linux 7.2 as it is.
could you please highlight what are the things we need to look into it .
in AIX we are using .netrc to store all FTP destination details servername,userid, password ...etc, will .netrc work in linux environment , if not what is the replacement of this file.
also please highlight the areas which we really need to look in terms after migration , currently we have just migrated our TEST box.
Thank you in advance.
rbatte1
November 17, 2016, 8:39am
2
By '...copied the complete AIX file system to linux....' can I assume that you mean the application filesystem? Overwriting operating system parts could cause unpredictable issues.
You might just find that the ftp client and server are not installed by default on your linux system (you don't say which supplier, which makes it tricky)
You might find vsftpd gives you this service, but you have to install it. You may also need to install an ftp client. What OS are you moving to? Common Linux providers are RedHat, CentOS, Debian, Mint, etc. and they all differ a bit on how you do things. Pasting the output from uname -a
(in CODE tags) would help us here.
As far as I know, the .netrc files should still be valid with any ftp client.
Remember that the client opens the connection to the server so you need to know which side is in charge. You may only need one of these packages.
Robin
To migrate an os totally different as AIX to Linux is impossible.
Is like to convert a BMW car to a Mercedes.
Is possible migrate an application like a ftp server of course
the same program,migrate the data then edit the file conf and make the corrections
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.
#!/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 #
###################################################################