Hey everyone,
Stonie Cooper gave me a script a few years ago to take the EMWIN FTP feed
and turn it into an IDS|DDPLUS feed. You will need to change a few things:
I put the FTP files downloaded into a temp directory, and you will likely
need to change the name of your ldm.pq file path. These are the first two
uncommented lines in the script below. You must also have wget installed
on your system. If you are not using CentOS/RHEL, this script may or may
not work. After putting this script into a file, run it from cron, like
so:
#*/1 * * * * /home/ldm/wxpscripts/grabemwin > /dev/null 2>&1
Change the path, obviously, to where the script is. Run the script "by
hand" by typing in "grabemwin" and it should work. Have a second window
open running "ldmadmin watch" to see if it is working. If it is, once a
minute, you'll see IDS|DDPLUS products fly by. These download the FTP
files once a minute (some once every 2, 5 or 15 minutes) and then slap on
IDS|DDPLUS headers.
Thank you, thank you, thank you Stonie Cooper from Planetary Data, Inc.,
for giving me permission to take my slightly modified version and share it
with you all. This is the exact script I am using to feed Gerry Creager
and my downstream sites.
*******************************************************************************
Gilbert Sebenste ********
(My opinions only!) ******
Staff Meteorologist, Northern Illinois University ****
E-mail: sebenste@xxxxxxxxxxxxxxxxxxxxx ***
web: http://weather.admin.niu.edu **
*******************************************************************************
# ! /bin/bash
# Copyright under the GPL, 2007, by Stonie R. Cooper of
# Planetary Data, Incorporated.
# This script and any derivative work must contain this header
# credits/license information.
# stonie<dot>cooper<at>planetarydata<dot>com
# There is no warranty to the fitness of this script, it's
# usefullness, freedom of bugs, etc. This is as-is - use
# at your own risk.
TEMPDIR="/tmp/emwin"
QUEUELOC="/home/ldm/data/ldm.pq"
ELOGIN="emwin:emwin@"
EHOST="140.90.6.240"
TIMESLOTS=( \
"2" \
"5" \
"15" \
"60" \
"180" \
)
FILESLOTS=( \
"twomins.zip:newtwomins.zip" \
"fivemins.zip:newfivemins.zip" \
"fifteen.zip:imagegif.zip:newfifteen.zip" \
"oneimage.zip:onetext.zip:newonetext.zip" \
"newthreetxt.zip:threeimg.zip:threetxt.zip" \
)
DATASLOTS="TXT:IDS|DDPLUS:Y:HEADER GIF:EXP:N:FILE"
#DATASLOTS="TXT:EXP:Y:HEADER GIF:EXP:N:FILE"
if [ -r /etc/profile ]; then
source /etc/profile
fi
if [ -r /home/ldm/.bash_profile ]; then
source /home/ldm/.bash_profile
fi
if [ -r /home/ldm/.bashrc ]; then
source /home/ldm/.bashrc
fi
#if [ -z "${GEMPAK}" ]; then
# if [ -r /usr/local/nawips/Gemenviron.profile ]; then
# source /usr/local/nawips/Gemenviron.profile
# else
# exit
# fi
# fi
THISHOUR=`date -u "+%H"`
THISMINUTE=`date -u "+%M"`
THISCOUNT="0"
THISLIST=""
REMAINDER=`echo "${THISMINUTE} % 2" | bc`
if [ "${REMAINDER}" -eq 0 ]; then
THISCOUNT="1"
THISLIST="0"
fi
REMAINDER=`echo "${THISMINUTE} % 5" | bc`
if [ "${REMAINDER}" -eq 0 ]; then
THISCOUNT=`expr "${THISCOUNT}" + 1`
THISLIST="${THISLIST} 1"
fi
REMAINDER=`echo "${THISMINUTE} % 15" | bc`
if [ "${REMAINDER}" -eq 0 ]; then
THISCOUNT=`expr "${THISCOUNT}" + 1`
THISLIST="${THISLIST} 2"
fi
if [ "${THISMINUTE}" -eq 1 ]; then
THISCOUNT=`expr "${THISCOUNT}" + 1`
THISLIST="${THISLIST} 3"
fi
REMAINDER=`echo "${THISHOUR} % 3" | bc`
if [ "${REMAINDER}" -eq 0 -a "${THISMINUTE}" -eq 1 ]; then
THISCOUNT=`expr "${THISCOUNT}" + 1`
THISLIST="${THISLIST} 4"
fi
if [ "${THISCOUNT}" -eq 0 ]; then
exit
fi
THISLIST=( ${THISLIST} )
INTERNALCOUNT="0"
sleep 10
while [ "${INTERNALCOUNT}" -lt "${THISCOUNT}" ]
do
if [ ! -d ${TEMPDIR}/${TIMESLOTS[${THISLIST[${INTERNALCOUNT}]}]} ]; then
mkdir -p ${TEMPDIR}/${TIMESLOTS[${THISLIST[${INTERNALCOUNT}]}]}
fi
if [ ! -d ${TEMPDIR}/${TIMESLOTS[${THISLIST[${INTERNALCOUNT}]}]} ]; then
exit
fi
cd ${TEMPDIR}/${TIMESLOTS[${THISLIST[${INTERNALCOUNT}]}]}
LOCATION=`pwd`
if [ "${TEMPDIR}/${TIMESLOTS[${THISLIST[${INTERNALCOUNT}]}]}" !=
"${LOCATION}" ]; then
exit
fi
for EACHZIP in `echo "${FILESLOTS[${THISLIST[${INTERNALCOUNT}]}]}" | tr ':'
' '`
do
wget --passive-ftp -q ftp://${ELOGIN}${EHOST}/${EACHZIP}
unzip -qq ${EACHZIP} > /dev/null 2>&1
rm -f ${EACHZIP}
FILECOUNT="0"
for eachFile in `find . -type f ! -empty -print`
do
FILECOUNT=`expr "${FILECOUNT}" + 1`
if [ "${FILECOUNT}" -gt 999 ]; then
FILECOUNT="1"
fi
SEQUENCE=`printf "%03d" "${FILECOUNT}"`
SEQUENCE="999"
HEADER=`head -c 27 ${eachFile} | tr '\r' '_' | sed "s/__//g"`
WMO=`echo ${HEADER} | cut -c1-18`
PIL=`echo ${HEADER} | cut -c20- | tr '_' ' '`
PIL=`echo ${PIL} | grep ^[A-Z]`
if [ -n "${PIL}" ]; then
PIL=`echo ${PIL} | awk -F" " '{print $1}'`
PILSIZE=`echo ${PIL} | wc -c`
if [ ${PILSIZE} -gt 4 ]; then
PRODUCT=`printf "%s /p%s" "${WMO}" "${PIL}"`
else
PRODUCT="${WMO}"
fi
else
PRODUCT="${WMO}"
fi
THISFILE=`echo ${eachFile} | awk -F"/" '{print $NF}'`
FILETYPE=`echo "${THISFILE}" | awk -F"." '{print $2}'`
THISFEEDTYPE="EXP"
THISPREAMBLE="Y"
THISPRODUCT="HEADER"
for EACHTYPEINLIST in `echo "${DATASLOTS}"`
do
SUFFIX=`echo "${EACHTYPEINLIST}" | awk -F":" '{print $1}'`
FEEDTYPE=`echo "${EACHTYPEINLIST}" | awk -F":" '{print $2}'`
PREAMBLE=`echo "${EACHTYPEINLIST}" | awk -F":" '{print $3}'`
HPRODUCT=`echo "${EACHTYPEINLIST}" | awk -F":" '{print $4}'`
if [ "${FILETYPE}" = "${SUFFIX}" ]; then
THISFEEDTYPE="${FEEDTYPE}"
THISPREAMBLE="${PREAMBLE}"
THISPRODUCT="${HPRODUCT}"
fi
done
if [ "${THISPREAMBLE}" = "Y" ]; then
printf "\001\r\r\n%s\r\r\n" "${SEQUENCE}" > temp
fi
cat ${eachFile} >> temp
if [ "${THISPREAMBLE}" = "Y" ]; then
BOOL=`cat temp | tr '\003' '@' | grep "@" | wc -l | awk -F" " '{print
$1}'`
if [ ${BOOL} -eq 0 ]; then
printf "\r\r\n\003" >> temp
fi
fi
if [ "${THISPRODUCT}" = "HEADER" ]; then
pqinsert -q ${QUEUELOC} -s ${SEQUENCE} -f "${THISFEEDTYPE}" -p
"${PRODUCT}" temp > /dev/null 2>&1
elif [ "${THISPRODUCT}" = "FILE" ]; then
pqinsert -q ${QUEUELOC} -s ${SEQUENCE} -f "${THISFEEDTYPE}" -p "EMWIN
F/${THISFILE}" temp > /dev/null 2>&1
fi
rm -f ${eachFile} temp
done
rm -rf *
done
INTERNALCOUNT=`expr "${INTERNALCOUNT}" + 1`
done