#### UNIX Script Documentation Block # # Script name: ingest_get # # JIF contact: Keyser org: NP22 date: 2010-07-06 # # Abstract: Transfers a file from a remote unix machine to the NCEP CCS. The # transfer involves no data conversion. # # Script history log: # 2006-05-12 D. Keyser Original version for implementation. Combines/ # generalizes previous scripts ingest_cemscsget (for CEMSCS machine only) # and ingest_unixget (for unix machines only), and changed to account for # all remote machines now being unix (since MVS CEMSCS machine was replaced # with unix DDS machine). Improved documentation and comments, more # appropriate messages posted to joblog. # 2007-06-12 D. Keyser Modified to perform a "passive" ftp to the remote # machine. Instead of the client (the CCS) initiating a connection, then # the server (the remote machine) initiating a second, the client initiates # both connections. This corrects the "socket error" which had been # occurring in about 1 in 500 ftp attempts to NESDIS' DDS machine. # 2007-10-24 D. Keyser Modified to add the remote and local file names on # the same line as the "get" command in the ftp logic. The previous form, # with "get", remote file and local file on separate lines, no longer works # on the NCEP CCS Dew machine due to a change in the ftp client software. # 2010-06-24 P. O'Reilly Modified to remove section that creates special # .netrc for the gp16.ssd.nesdis.noaa.gov system. This system has been # retired. # 2010-07-06 D. Keyser Modified to pull files from either CCS machine via # sftp, # # Usage: ingest_get remote_machine local_file remote_file # # Script parameters: (1) remote_machine # (2) local_file # (3) remote_file # # Modules and files referenced: # scripts : none # data cards : none # executables: none # # Remarks: Invoked by the ush scripts ingest_process_days and # ingest_process_orbits. # # Condition codes: # 0 - no problem encountered # > 0 - some problem encountered # Specifically: 1 - Tranfser of file failed # # Attributes: # Language: aix unix script # Machine: NCEP CCS #### set -au echo echo "#######################################################################" echo " START INGEST_GET " echo "#######################################################################" echo DEBUGSCRIPTS=${DEBUGSCRIPTS:-OFF} if [ $DEBUGSCRIPTS = ON -o $DEBUGSCRIPTS = YES ] ; then set -x fi if [ $# -ne 3 ] ; then echo "Arguments to ingest_get:" echo " (1) remote_machine" echo " (2) local_file" echo " (3) remote_file" exit 0 fi MACHINE="$1" LOCDSN="$2" REMOTEDSN="$3" ftout=$DATA/ftout$$ if [ $MACHINE = prodccs.ncep.noaa.gov -o $MACHINE = devccs.ncep.noaa.gov ]; then echo echo "Use SFTP." echo sftp -v $MACHINE <$ftout 2>&1 get $REMOTEDSN $LOCDSN quit EOH_sftp else echo echo "Use FTP." echo ftp -vi $MACHINE <$ftout 2>&1 passive binary get $REMOTEDSN $LOCDSN quit EOH_ftp fi ### end ftp instruction input ### ftperror=$? # Cat out the standard output from the ftp and remove it # ------------------------------------------------------ set +x echo echo "Time is now $(date)." echo grep "transfer aborted" $ftout errgrep=$? cat $ftout echo [ $DEBUGSCRIPTS = ON -o $DEBUGSCRIPTS = YES ] && set -x rm $ftout if [ $ftperror -ne 0 ] || [ ! -s $LOCDSN ] || [ $errgrep -eq 0 ]; then echo " Transfer of file $REMOTEDSN from $MACHINE failed." exit 1 fi exit 0