arrays - Script terminates prematurely after do loop. Last "echo" is not executed. -
i looking execute following script below. issue encountering not execute after loop. doesn't matter happen have after loop, never executes, def missing somewhere.
also, suggestions on more efficient way or writing script? new scripting environment , open better ways of going things.
#!/bin/bash # mcidas environment path=$home/bin: path=$path:/usr/sww/bin:/usr/local/bin:$home/mcidas/bin path=$path:/home/mcidas/bin:/bin:/usr/bin:/etc:/usr/ucb path=$path:/usr/bin/x11:/common/tool/bin:. export path mcpath=$home/mcidas/data mcpath=$mcpath:/home/mcidas/data export mcpath #variables basedir1="ftp://ladsweb.nascom.nasa.gov/alldata/6/mod02qkm" #terra basedir2="ftp://ladsweb.nascom.nasa.gov/alldata/6/myd02qkm" #aqua day=`date +%j` day1=`date +"%j" -d "-1 day"` hour=`date -u +"%h"` min=`date -u +"%m"` year=`date -u +"%y"` segment=1 count=$(ls /satellite/modis_processed/ | grep -v ^d | wc -l) count_max=25 files=(/satellite/modis_processed/*) if [ $hour -ge "17" ]; workinghour="16" echo "searching hour $workinghour" url="${basedir2}/${year}/${day1}/myd02qkm.a${year}${day1}.${workinghour}*.006.${year}*" wget -r -nd --no-parent -nc -e robots=off -r 'index.*' -p /satellitemodis/ $url #find /satellite/modis/ -type f -mmin -30 -exec cp "{}" /satellite/modis_processed/ \; files in /satellite/modis_processed/* echo "the number used data file ${count}" echo "the number used image file ${segment}" export segment export count #run mcidas mcenv <<- 'eof' imgcopy.k modisd.${count} modisi.${segment} band=1 size=same imgremap.k modisd.${segment} modisi.${segment} band=1 size=all pro=merc imgcha.k modisi.${segment} ctype=brit exit eof segment=`expr ${segment} + 1` count=`expr ${count} - 1` #reset counter if equal or greater 25 if [[ $segment -ge $count_max ]]; segment=1 fi find /satellite/awips -type f -name "area62*" -exec mv "{}" /awips2/edex/data/manual/ \; done; echo "we have exported ${segment} converted modis files edex." fi
you have here-document in script. here-document not terminated. end marker, eof
, needs in first column, not indented @ all.
if indent it, has tabs, , start of here-document should <<-'eof'
.
the effect of wrongly indented eof
marker rest of script read contents of here-document.
as charles duffy points out, shellcheck friend.
Comments
Post a Comment