HP3000-L Archives

October 2003, 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:
Joshua Johnson <[log in to unmask]>
Reply To:
Date:
Mon, 6 Oct 2003 14:04:26 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (119 lines)
Dave writes
I have run into this problem in the past.  It still continues to be a
problem.  The only way I have found to reliably determine if FTP has
completed the task is to set my own VARs. Before you enter FTP, set a VAR to
indicate that your ftp has failed.  Then, inside FTP, after you issue the
PUT, GET etc. follow it with a :setvar to indicate that the FTP completed
successfully.  I have not found a case yet that FTP did not exit on an
error, however it does not always set it's own VARs to indicate so.  If an
error occurs the :setvar will not be executed and the original value will
indicate that the FTP failed.
Example:

SETVAR FTP_OK FALSE
ftp
open host
user user
password
exitonerror
put file1 file2
:SETVAR FTP_OK TRUE
quit
*********************************

I took this a step further and used setvar _ft_lastcmd and :if to check the
FTP variables, then set my own variables before I exti ftp. This logic has
worked great for me. Here is an example. As youy can see this logic is part
of a greater ftp tool that has node, user, pass, directories, etc stored in
an image database so my jobs call this tool with a key value which is used
to get everything from the database. This works great when changes occur
that affect ftp's from jobs. I also allow one call to my tool to generate
multiple ftp's. This is great when a job needs to send a file to multiple
servers, it is all handled with one call to this ftp tool. There is also a
retry job wich will retransmit failed ftp's once the problem has been
resolved. Using this logic I am able to determine what command I failed on,
etc.

If anyone on the list if interested in this code I would be happy to share.
It used a quick screen to enter data into the database but that could be
done with something else if you don't have Cognos. It used a Cobol program
to get the data from the database. The ftp command is all CI code and the
retry job is written in MPEX. It even puts out recalls and send event
messages when ftp's fail. The operators simply reply to the recall to
retransmit the file. Of course it also logs everything to a log dataset in
the image database as well.

# Create temporary file to used as STDIN on FTP run.
    echo EXITONERROR                                 >  *!_ft_tmpin
    echo :setvar _ft_lastcmd 'OPEN'                  >> *!_ft_tmpin
    echo OPEN !_ft_rmnode                            >> *!_ft_tmpin

    echo :setvar _ft_lastcmd 'USER'                  >> *!_ft_tmpin
    echo USER !_ft_rmuname                           >> *!_ft_tmpin
    echo !_ft_rmpass                                 >> *!_ft_tmpin
    echo :if lft(ftplastreply,2)='53'                >> *!_ft_tmpin
    echo :  setvar _ft_fail true                     >> *!_ft_tmpin
    echo :  setvar _ft_failuser true                 >> *!_ft_tmpin
    echo :endif                                      >> *!_ft_tmpin

    if _ft_type="B"
      echo type binary                               >> *!_ft_tmpin
    endif

    if _ft_rmdir<>''
      echo :setvar _ft_lastcmd 'CD'                  >> *!_ft_tmpin
      echo CD ![rtrim(_ft_rmdir,'/')]                >> *!_ft_tmpin
      echo :if lft(ftplastreply,2)='55'              >> *!_ft_tmpin
      echo :  setvar _ft_fail true                   >> *!_ft_tmpin
      echo :  setvar _ft_failcd true                 >> *!_ft_tmpin
      echo :endif                                    >> *!_ft_tmpin
    endif

    if _ft_renorcnf='N'
      echo EXITONERROR                               >> *!_ft_tmpin
      echo DEL ./!_ft_lcfile                         >> *!_ft_tmpin
      echo EXITONERROR                               >> *!_ft_tmpin
    endif

    echo :setvar _ft_lastcmd 'PUTLC'                 >> *!_ft_tmpin
    echo PUT !_ft_lcdir!_ft_lcfile ./!_ft_tempput    >> *!_ft_tmpin
    echo :if lft(ftplastreply,2)='52'                >> *!_ft_tmpin
    echo :  setvar _ft_fail true                     >> *!_ft_tmpin
    echo :  setvar _ft_failputlc true                >> *!_ft_tmpin
    echo :endif                                      >> *!_ft_tmpin
    echo :pause 10                                   >> *!_ft_tmpin
    echo :setvar _ft_lastcmd 'REN'                   >> *!_ft_tmpin

    echo REN ./!_ft_tempput ./!_ft_lcfile            >> *!_ft_tmpin
    echo :if lft(ftplastreply,2)='55'                >> *!_ft_tmpin
    echo :  setvar _ft_fail true                     >> *!_ft_tmpin
    echo :  setvar _ft_failren true                  >> *!_ft_tmpin
    echo :endif                                      >> *!_ft_tmpin

    if _ft_renorcnf='C'
      echo :setvar _ft_lastcmd 'PUTCF'               >> *!_ft_tmpin
      echo PUT ./!_ft_conf ./!_ft_confname           >> *!_ft_tmpin
      echo :if lft(ftplastreply,2)='52'              >> *!_ft_tmpin
      echo :  setvar _ft_fail true                   >> *!_ft_tmpin
      echo :  setvar _ft_failputcf true              >> *!_ft_tmpin
      echo :endif                                    >> *!_ft_tmpin
    endif

    echo :setvar _ft_lastcmd 'FINISH'                >> *!_ft_tmpin
    echo QUIT                                        >> *!_ft_tmpin

# Call FTP and then check for errors.
    if _ftr_callfromretry
      continue
      withcaps 'sm',run ftp.arpa.sys;stdin=*!_ft_tmpin;stdlist=*!_ft_list
    else
      continue
      run ftp.arpa.sys;stdin=*!_ft_tmpin;stdlist=*!_ft_list
    endif
...

Josh

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

ATOM RSS1 RSS2