HP3000-L Archives

March 2002, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Tue, 5 Mar 2002 10:51:43 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (67 lines)
Not really. On what platform do your ftp scripts live? If you know, or are
willing to learn perl, you can do this one better, as perl provides the
results of most any statement such that it can be scripted for testing and
validating.

On MS OSs, when installing perl was not considered, I have used a generic
batch file to redirect the output of the ftp into a log file, and then use
find to test the contents of the log file. The batch file expects an ftp
command file as its argument, and writes its output to the same base
filename, with the extension .log, which is what makes it generic. For
instance:
@echo off
REM check for ftpCommandFileName parm
IF %1!==! ECHO %0 takes ftpCommandFileName
IF %1!==! GOTO EXIT
REM handle second parm; if found, ensure that the hour contains a space and
a colon
IF %2!==! SET HOUR=
IF NOT %2!==! SET HOUR= %2
IF NOT %2!==! ECHO %2|FIND ":"
IF NOT %2!==! IF ERRORLEVEL==1 SET HOUR=%HOUR%:
REM date stamp the log file
echo|more|date|find /i "current" > %1.log
REM retry loop label
:LOOP
REM time stamp the log file
ECHO|MORE|TIME|FIND /I "current">>%1.LOG
REM run ftp, nonverbose, no autologon, specifying command file
ftp -v -n -s:%1.txt >> %1.log
REM check log for "transfer complete" message; if not found, echo fail
message
FIND /i "transfer complete" %1.log
IF NOT ERRORLEVEL==1 GOTO EXIT
ECHO %0 %1 failed!
ECHO %0 %1 failed! >> %1.log
REM if the second parm for hour was supplied, check time, and exit if found,
or sleep and retry
IF %HOUR%!==! GOTO EXIT
ECHO|MORE|TIME|FIND /I "current"|FIND "%HOUR%"
IF NOT ERRORLEVEL==1 ECHO Ending loop>>%1.LOG
IF NOT ERRORLEVEL==1 GOTO EXIT
SLEEP %3
GOTO LOOP
:EXIT
SET HOUR=

This can be greatly simplified, depending on your needs. This version
contains a test for an hour, which, when provided as the second parm, allows
the batch file to loop until that hour, but then end at that hour. With no
second parm, it just runs once (also the case if your ftp works the first
time). Also, the sleep interval is the third parm. Sleep is a utility from
the NT reskit, but similar utilities are easy enough to find. Even CHOICE
can be abused to provide a sleep interval. Also, it uses some pre-NT
artifacts, in case older OSs need to be supported. The kludge to log the
time and date can be replace with time /t or date /t, although the FIND
needs to test for the appropriate format. And under NT and later, the :EXIT
label is not needed, as EXIT is a command, and can replace GOTO EXIT, where
you do not need any post-processing clean up. Removing the HOUR variable is
good housekeeping, and useful for testing, but not of much use in
production.

Greg Stigers
http://www.cgiusa.com

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2