ftpsri.sh

InfoInfo
Search:    

# Shell Script: ftpsri.sh
# Execute: ./ftpsri.sh
# Created by Erik Johnson July 2007
# Last Modified 8/23/07 by Erik Johnson
# This program is run at :00, :15, :30, :45 of every hour of every day by the maccs user crontab.
# It downloads the latest MACCS raw data files from SRI's ftp site and files them into the MACCS_DATA/Raw/ folder.
# Then it makes ASCII files and line plots of the data it downloaded.
# It runs todaysdata.sh which copies today's line plot files to the web server for the Today's Real-Time Data Plots web page
# It calls the following idl programs (from the /Volumes/physics_data/Code/MACCS_Code/ directory) to process the data:
# IridiumMaccs2.pro to make Augsburg Format ASCII files which are used by linex7.pro
# IridiumMaccs3.pro to make IAGA2000 Format ASCII files which are made available on the MACCS iridium website
# linex7.pro to make line plots of the data which are made available on the MACCS iridium website

#Get the current year, julian day and previous 6 days in UTC
YEAR=`date -u +%Y`
YY=`date -u +%y`
DAY=`date -u +%j`
#NDAY=`echo $DAY + 1 | bc`
PDAY=`echo $DAY - 1 | bc`
P2DAY=`echo $DAY - 2 | bc`
P3DAY=`echo $DAY - 3 | bc`
P4DAY=`echo $DAY - 4 | bc`
P5DAY=`echo $DAY - 5 | bc`
P6DAY=`echo $DAY - 6 | bc`

SOURCEdir='/Volumes/physics_data/Code/MACCS_Code/'
CDdir='/Volumes/physics_data/Ftp/MACCS_DATA/Raw/CD/Iridium/'${YEAR}'ir/'
NAdir='/Volumes/physics_data/Ftp/MACCS_DATA/Raw/NA/Iridium/'${YEAR}'ir/'
CDAdir='/Volumes/physics_data/Ftp/MACCS_DATA/AugASCII/CD/'${YEAR}'ir/'
NAAdir='/Volumes/physics_data/Ftp/MACCS_DATA/AugASCII/NA/'${YEAR}'ir/'
CDIdir='/Volumes/physics_data/Ftp/MACCS_DATA/IAGA2000/CD/'${YEAR}'ir/'
NAIdir='/Volumes/physics_data/Ftp/MACCS_DATA/IAGA2000/NA/'${YEAR}'ir/'
CDLdir='/Volumes/physics_data/Ftp/MACCS_DATA/LinePlots/PostScript/CD/'${YEAR}'ir/'
NALdir='/Volumes/physics_data/Ftp/MACCS_DATA/LinePlots/PostScript/NA/'${YEAR}'ir/'
CDL2dir='/Volumes/physics_data/Ftp/MACCS_DATA/LinePlots/PNG/CD/'${YEAR}'ir/'
NAL2dir='/Volumes/physics_data/Ftp/MACCS_DATA/LinePlots/PNG/NA/'${YEAR}'ir/'

#insert the necessary leading zeros for DAY
#if [ $DAY -lt 10 ]; then
# DAY=00$DAY
#elif [ $DAY -lt 100 ]; then
# DAY=0$DAY
#fi

#if [ $NDAY -lt 10 ]; then
# NDAY=00$NDAY
#elif [ $NDAY -lt 100 ]; then
# NDAY=0$NDAY
#fi
if [ $PDAY -lt 10 ]; then

elif [ $PDAY -lt 100 ]; then

fi
if [ $P2DAY -lt 10 ]; then

elif [ $P2DAY -lt 100 ]; then

fi
if [ $P3DAY -lt 10 ]; then

elif [ $P3DAY -lt 100 ]; then

fi
if [ $P4DAY -lt 10 ]; then

elif [ $P4DAY -lt 100 ]; then

fi
if [ $P5DAY -lt 10 ]; then

elif [ $P5DAY -lt 100 ]; then

fi
if [ $P6DAY -lt 10 ]; then

elif [ $P6DAY -lt 100 ]; then

fi

#Get the maccs iridium raw data files from SRI if they are different in file size from the ones we have.
#If a new file was downloaded, make an Augsburg format ASCII file, a IAGA2000 format ASCII file,
#and a line plot of the data.

#Get the sizes of our files if they exits
#If the data has been moved into the Problem_Data folder, set PROB=1 else set PROB=0
cd $CDdir
if [ -f "CD${YY}${P6DAY}.dat" ]; then

elif [ -f "Problem_Data/CD${YY}${P6DAY}.dat" ]; then

else

fi
cd $CDdir
if [ -f "CD${YY}${P5DAY}.dat" ]; then

elif [ -f "Problem_Data/CD${YY}${P5DAY}.dat" ]; then

else

fi
cd $CDdir
if [ -f "CD${YY}${P4DAY}.dat" ]; then

elif [ -f "Problem_Data/CD${YY}${P4DAY}.dat" ]; then

else

fi
cd $CDdir
if [ -f "CD${YY}${P3DAY}.dat" ]; then

elif [ -f "Problem_Data/CD${YY}${P3DAY}.dat" ]; then

else

fi
cd $CDdir
if [ -f "CD${YY}${P2DAY}.dat" ]; then

elif [ -f "Problem_Data/CD${YY}${P2DAY}.dat" ]; then

else

fi
cd $CDdir
if [ -f "CD${YY}${PDAY}.dat" ]; then

elif [ -f "Problem_Data/CD${YY}${PDAY}.dat" ]; then

else

fi
cd $CDdir
if [ -f "Problem_Data/CD${YY}${DAY}.dat" ]; then

else

fi
cd $NAdir
if [ -f "Problem_Data/NA${YY}${DAY}.dat" ]; then

else

fi

if [ "$P6DAYSIZE" != 3283200 ]; then
cd $CDdir
if [ "$P6DAYPROB" = 1 ]; then

fi
echo CD P6DAY file is incomplete or missing, downloading P6DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/CD/magnetometer/
get CD${YY}${P6DAY}.dat
bye
END_SCRIPT
if [ -f "CD${YY}${P6DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$P5DAYSIZE" != 3283200 ]; then
cd $CDdir
if [ "$P5DAYPROB" = 1 ]; then

fi
echo CD P5DAY file is incomplete or missing, downloading P5DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/CD/magnetometer/
get CD${YY}${P5DAY}.dat
bye
END_SCRIPT
if [ -f "CD${YY}${P5DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$P4DAYSIZE" != 3283200 ]; then
cd $CDdir
if [ "$P4DAYPROB" = 1 ]; then

fi
echo CD P4DAY file is incomplete or missing, downloading P4DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/CD/magnetometer/
get CD${YY}${P4DAY}.dat
bye
END_SCRIPT
if [ -f "CD${YY}${P4DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$P3DAYSIZE" != 3283200 ]; then
cd $CDdir
if [ "$P3DAYPROB" = 1 ]; then

fi
echo CD P3DAY file is incomplete or missing, downloading P3DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/CD/magnetometer/
get CD${YY}${P3DAY}.dat
bye
END_SCRIPT
if [ -f "CD${YY}${P3DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$P2DAYSIZE" != 3283200 ]; then
cd $CDdir
if [ "$P2DAYPROB" = 1 ]; then

fi
echo CD P2DAY file is incomplete or missing, downloading P2DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/CD/magnetometer/
get CD${YY}${P2DAY}.dat
bye
END_SCRIPT
if [ -f "CD${YY}${P2DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$PDAYSIZE" != 3283200 ]; then
cd $CDdir
if [ "$PDAYPROB" = 1 ]; then

fi
echo CD PDAY file is incomplete or missing, downloading PDAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/CD/magnetometer/
get CD${YY}${PDAY}.dat
bye
END_SCRIPT
if [ -f "CD${YY}${PDAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

echo Downloading data files from today
cd $CDdir
if [ "$CDDAYPROB" = 1 ]; then

fi
if [ "$NADAYPROB" = 0 ]; then

END_SCRIPT
else

END_SCRIPT

END_SCRIPT
fi

cd $CDdir
if [ -f "CD${YY}${DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT
elif [ "$CDDAYPROB" = 1 ]; then

END_SCRIPT

END_SCRIPT

fi

cd $NAdir
if [ -f "NA${YY}${DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT
elif [ "$NADAYPROB" = 1 ]; then

END_SCRIPT

END_SCRIPT

fi

#Get the sizes of our NA files if they exits and test if the data is in the Problem_Data folder
cd $NAdir
if [ -f "NA${YY}${P6DAY}.dat" ]; then

elif [ -f "Problem_Data/NA${YY}${P6DAY}.dat" ]; then

else

fi
cd $NAdir
if [ -f "NA${YY}${P5DAY}.dat" ]; then

elif [ -f "Problem_Data/NA${YY}${P5DAY}.dat" ]; then

else

fi
cd $NAdir
if [ -f "NA${YY}${P4DAY}.dat" ]; then

elif [ -f "Problem_Data/NA${YY}${P4DAY}.dat" ]; then

else

fi
cd $NAdir
if [ -f "NA${YY}${P3DAY}.dat" ]; then

elif [ -f "Problem_Data/NA${YY}${P3DAY}.dat" ]; then

else

fi
cd $NAdir
if [ -f "NA${YY}${P2DAY}.dat" ]; then

elif [ -f "Problem_Data/NA${YY}${P2DAY}.dat" ]; then

else

fi
cd $NAdir
if [ -f "NA${YY}${PDAY}.dat" ]; then

elif [ -f "Problem_Data/NA${YY}${PDAY}.dat" ]; then

else

fi

#Download data from each of the previous 6 days if our data for that day is incomplete or missing
if [ "$P6DAYSIZE" != 3283200 ]; then
cd $NAdir
if [ "$P6DAYPROB" = 1 ]; then

fi
echo NA P6DAY file is incomplete or missing, downloading P6DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/NA/magnetometer/
get NA${YY}${P6DAY}.dat
bye
END_SCRIPT
if [ -f "NA${YY}${P6DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$P5DAYSIZE" != 3283200 ]; then
cd $NAdir
if [ "$P5DAYPROB" = 1 ]; then

fi
echo NA P5DAY file is incomplete or missing, downloading P5DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/NA/magnetometer/
get NA${YY}${P5DAY}.dat
bye
END_SCRIPT
if [ -f "NA${YY}${P5DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$P4DAYSIZE" != 3283200 ]; then
cd $NAdir
if [ "$P4DAYPROB" = 1 ]; then

fi
echo NA P4DAY file is incomplete or missing, downloading P4DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/NA/magnetometer/
get NA${YY}${P4DAY}.dat
bye
END_SCRIPT
if [ -f "NA${YY}${P4DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$P3DAYSIZE" != 3283200 ]; then
cd $NAdir
if [ "$P3DAYPROB" = 1 ]; then

fi
echo NA P3DAY file is incomplete or missing, downloading P3DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/NA/magnetometer/
get NA${YY}${P3DAY}.dat
bye
END_SCRIPT
if [ -f "NA${YY}${P3DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$P2DAYSIZE" != 3283200 ]; then
cd $NAdir
if [ "$P2DAYPROB" = 1 ]; then

fi
echo NA P2DAY file is incomplete or missing, downloading P2DAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/NA/magnetometer/
get NA${YY}${P2DAY}.dat
bye
END_SCRIPT
if [ -f "NA${YY}${P2DAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

if [ "$PDAYSIZE" != 3283200 ]; then
cd $NAdir
if [ "$PDAYPROB" = 1 ]; then

fi
echo NA PDAY file is incomplete or missing, downloading PDAY file
ftp -n << END_SCRIPT
open 128.18.144.24
user anonymous teakjohnson@embarqmail.com
epsv4
cd pub/maccs/NA/magnetometer/
get NA${YY}${PDAY}.dat
bye
END_SCRIPT
if [ -f "NA${YY}${PDAY}.dat" ]; then

END_SCRIPT

END_SCRIPT

fi
fi

cd $SOURCEdir
./todaysdata.sh

This is a Wiki Spot wiki. Wiki Spot is a non-profit organization that helps communities collaborate via wikis.