variable question - Hewlett Packard

This is a discussion on variable question - Hewlett Packard ; hello, My file name,remotefile, is not coming out like I thought. I am trying to name the file "cntr" and concatenate the month and year to the file name. What I am getting is this : "!file_name". Can you see ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: variable question

  1. variable question

    hello,

    My file name,remotefile, is not coming out like I thought. I am trying to name
    the file "cntr" and concatenate the month and year to the file name. What I
    am getting is this : "!file_name". Can you see what I am doing wrong?
    Thanks!

    !setvar file_name ' '
    !setvar remotefile ' '
    !setvar mon ' '
    !setvar yr ' '
    !setvar mon '!hpmonth'
    !setvar yr '!hpyear'
    !setvar file_name 'CNTR!mon!yr'
    !setvar remotefile "!file_name"
    !COMMENT

    !FTP
    OPEN
    USER
    !put !remotefile

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


  2. Re: variable question

    mag wrote:
    > hello,
    >
    > My file name,remotefile, is not coming out like I thought. I am trying to name
    > the file "cntr" and concatenate the month and year to the file name. What I
    > am getting is this : "!file_name". Can you see what I am doing wrong?
    > Thanks!


    Fox 11:setvar remotefile "CNTR!HPYEAR!HPMONTH"
    Fox 11:showvar remotefile
    REMOTEFILE = CNTR711
    Fox 11:setvar remotefile "CNTR"+RHT("0!HPYEAR",2)+RHT("0!HPMONTH",2)
    Fox 11:showvar remotefile
    REMOTEFILE = CNTR0711
    Fox 11:

    Keven

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


  3. Re: variable question

    Mag:

    Remove the quotes on the second to last command > setvar remotefile
    !file_name

    Olav.

    mag wrote:

    >hello,
    >
    >My file name,remotefile, is not coming out like I thought. I am trying to name
    >the file "cntr" and concatenate the month and year to the file name. What I
    >am getting is this : "!file_name". Can you see what I am doing wrong?
    >Thanks!
    >
    >!setvar file_name ' '
    >!setvar remotefile ' '
    >!setvar mon ' '
    >!setvar yr ' '
    >!setvar mon '!hpmonth'
    >!setvar yr '!hpyear'
    >!setvar file_name 'CNTR!mon!yr'
    >!setvar remotefile "!file_name"
    >!COMMENT
    >
    >!FTP
    >OPEN
    >USER
    >!put !remotefile
    >
    >* To join/leave the list, search archives, change list settings, *
    >* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
    >
    >
    >


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


  4. Re: variable question

    First off, FTP can't expand variables, but :echo can, so you need to build a
    file (any old temp file is ok), and redirect FTP's input to it, more or less
    like:

    !FILE FTPI = FTPI; REC=-72,,F,ASCII
    !ECHO exitonerror >> *FTPI
    !ECHO verbose >> *FTPI
    !ECHO open whatever >> *FTPI
    !ECHO user whoever>> *FTPI
    !ECHO put !remotefile >> *FTPI
    !ECHO quit >> *FTPI
    !
    !RUN FTP.ARPA.SYS < FTPI
    !IF FTPLASTERR <> 0
    ! some error routine, etc

    This will also give you better error checking if anything goes wrong.

    Also, you dont need the 1st 4 setvars that just dummy-out the variables you
    are going to set later.

    Also, it looks to me like your code would eat the leading zeros single-digits
    months. Try the "rht" function like Keven said

    ----- Original Message -----
    From: "mag"
    To:
    Sent: Friday, November 30, 2007 13:58
    Subject: [HP3000-L] variable question


    hello,

    My file name,remotefile, is not coming out like I thought. I am trying to
    name
    the file "cntr" and concatenate the month and year to the file name. What I
    am getting is this : "!file_name". Can you see what I am doing wrong?
    Thanks!

    !setvar file_name ' '
    !setvar remotefile ' '
    !setvar mon ' '
    !setvar yr ' '
    !setvar mon '!hpmonth'
    !setvar yr '!hpyear'
    !setvar file_name 'CNTR!mon!yr'
    !setvar remotefile "!file_name"
    !COMMENT

    !FTP
    OPEN
    USER
    !put !remotefile

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

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


  5. Re: variable question

    Opps, I did not see the FTP. So Dave is right. You need to pipe in
    your input if you are going to use FTP. The only way to do that is to
    echo everything needed for FTP into a file and use that as redirected input.

    Olav.

    Dave Powell, MMfab wrote:

    >First off, FTP can't expand variables, but :echo can, so you need to build a
    >file (any old temp file is ok), and redirect FTP's input to it, more or less
    >like:
    >
    >!FILE FTPI = FTPI; REC=-72,,F,ASCII
    >!ECHO exitonerror >> *FTPI
    >!ECHO verbose >> *FTPI
    >!ECHO open whatever >> *FTPI
    >!ECHO user whoever>> *FTPI
    >!ECHO put !remotefile >> *FTPI
    >!ECHO quit >> *FTPI
    >!
    >!RUN FTP.ARPA.SYS < FTPI
    >!IF FTPLASTERR <> 0
    >! some error routine, etc
    >
    >This will also give you better error checking if anything goes wrong.
    >
    >Also, you dont need the 1st 4 setvars that just dummy-out the variables you
    >are going to set later.
    >
    >Also, it looks to me like your code would eat the leading zeros single-digits
    >months. Try the "rht" function like Keven said
    >
    >----- Original Message -----
    >From: "mag"
    >To:
    >Sent: Friday, November 30, 2007 13:58
    >Subject: [HP3000-L] variable question
    >
    >
    >hello,
    >
    >My file name,remotefile, is not coming out like I thought. I am trying to
    >name
    >the file "cntr" and concatenate the month and year to the file name. What I
    >am getting is this : "!file_name". Can you see what I am doing wrong?
    >Thanks!
    >
    >!setvar file_name ' '
    >!setvar remotefile ' '
    >!setvar mon ' '
    >!setvar yr ' '
    >!setvar mon '!hpmonth'
    >!setvar yr '!hpyear'
    >!setvar file_name 'CNTR!mon!yr'
    >!setvar remotefile "!file_name"
    >!COMMENT
    >
    >!FTP
    >OPEN
    >USER
    >!put !remotefile
    >
    >* To join/leave the list, search archives, change list settings, *
    >* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
    >
    >* To join/leave the list, search archives, change list settings, *
    >* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
    >
    >
    >


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


  6. Re: variable question

    I have found setting passive to help make the transfer less likely to time out on you. Uses a different no of ports or something.

    jp
    ________________________________________
    From: HP-3000 Systems Discussion [HP3000-L@RAVEN.UTC.EDU] On Behalf Of OlavKappert [okappert@CANADA.COM]
    Sent: Saturday, 1 December 2007 12:55 PM
    To: HP3000-L@RAVEN.UTC.EDU
    Subject: Re: [HP3000-L] variable question

    Opps, I did not see the FTP. So Dave is right. You need to pipe in
    your input if you are going to use FTP. The only way to do that is to
    echo everything needed for FTP into a file and use that as redirected input...

    Olav.

    Dave Powell, MMfab wrote:

    >First off, FTP can't expand variables, but :echo can, so you need to builda
    >file (any old temp file is ok), and redirect FTP's input to it, more or less
    >like:
    >
    >!FILE FTPI = FTPI; REC=-72,,F,ASCII
    >!ECHO exitonerror >> *FTPI
    >!ECHO verbose >> *FTPI
    >!ECHO open whatever >> *FTPI
    >!ECHO user whoever>> *FTPI
    >!ECHO put !remotefile >> *FTPI
    >!ECHO quit >> *FTPI
    >!
    >!RUN FTP.ARPA.SYS < FTPI
    >!IF FTPLASTERR <> 0
    >! some error routine, etc
    >
    >This will also give you better error checking if anything goes wrong.
    >
    >Also, you dont need the 1st 4 setvars that just dummy-out the variables you
    >are going to set later.
    >
    >Also, it looks to me like your code would eat the leading zeros single-digits
    >months. Try the "rht" function like Keven said
    >
    >----- Original Message -----
    >From: "mag"
    >To:
    >Sent: Friday, November 30, 2007 13:58
    >Subject: [HP3000-L] variable question
    >
    >
    >hello,
    >
    >My file name,remotefile, is not coming out like I thought. I am trying to
    >name
    >the file "cntr" and concatenate the month and year to the file name. WhatI
    >am getting is this : "!file_name". Can you see what I am doing wrong?
    >Thanks!
    >
    >!setvar file_name ' '
    >!setvar remotefile ' '
    >!setvar mon ' '
    >!setvar yr ' '
    >!setvar mon '!hpmonth'
    >!setvar yr '!hpyear'
    >!setvar file_name 'CNTR!mon!yr'
    >!setvar remotefile "!file_name"
    >!COMMENT
    >
    >!FTP
    >OPEN
    >USER
    >!put !remotefile
    >
    >* To join/leave the list, search archives, change list settings, *
    >* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
    >
    >* To join/leave the list, search archives, change list settings, *
    >* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
    >
    >
    >


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

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


  7. Re: variable question

    Hello,

    When using FTP I have found that if a transfer fails part way into the
    transfer then you end up with an incomplete file on the remote system. To
    avoid incomplete files being processed. I have used a temp file name to
    perform the initial PUT command, then when the PUT is complete I call REN to
    give the file it's intended name. If the transfer fails the REN will never
    happen and the receiver will know the transfer failed. If the remote file
    exists or may exist you can call DEL first then PUT/REN. You must call
    EXITONERROR before your DEL command so it won't exit if the file doesn't
    exist, then EXITONERROR again after the delete command to set the flag back.
    Another solution is to use a second confirmation file that could included
    the EOF and/or byte count of the data file. Another problem I had was not
    all errors caused FTP to exit when exitonerror was set (can't remember which
    ones, too long ago). To determine the exact error I would colon to MPE and
    set a variable before the command, then colon to MPE after the command and
    set appropriate variables if it failed (snip example below). The variable
    FTPLASTREPLY is very helpful along with FTPLASTERR. To make your $STDLIST
    cleaner you can redirect the FTP output to a file and only display it if an
    error occurred (run ftp.arpa.sys;stdin=*!_ft_tmpin;stdlist=*!_ft_list) .

    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

    Several years ago I wrote an application that was a front end for regular
    FTP. It stored the user/password/remote directory, etc information in a
    database accessed with a Cobol program. The rest was all CI script. It had
    different configs for production/test/development environments so you could
    move a job/program through environments without any code changes for remote
    hosts, it would know where it was and use the configs for that environment.
    It had a method to determine what FTP command failed and then if appropriate
    would stage the transfer and keep trying until the server became
    available/issue resolved (background job handled retries). It did the rename
    thing of course and if the rename failed it would re-connect and delete the
    temp file so it didn't clutter up remote servers. It could transfer a file
    to multiple hosts with one call to the app. Then only stage hosts that
    failed. Logging everything too of course. It would do GET and DIR on remote
    hosts also. I have all the code if anyone is interested in FTP on steroids.
    It has a Quick screen to put the configs into the database, but you could
    use Query or Suprtool.

    Joshua Johnson

    -----Original Message-----
    From: HP-3000 Systems Discussion [mailto:HP3000-L@RAVEN.UTC.EDU] On Behalf
    Of John Pitman
    Sent: Friday, November 30, 2007 10:03 PM
    To: HP3000-L@RAVEN.UTC.EDU
    Subject: Re: [HP3000-L] variable question

    I have found setting passive to help make the transfer less likely to time
    out on you. Uses a different no of ports or something.

    jp
    ________________________________________
    From: HP-3000 Systems Discussion [HP3000-L@RAVEN.UTC.EDU] On Behalf Of Olav
    Kappert [okappert@CANADA.COM]
    Sent: Saturday, 1 December 2007 12:55 PM
    To: HP3000-L@RAVEN.UTC.EDU
    Subject: Re: [HP3000-L] variable question

    Opps, I did not see the FTP. So Dave is right. You need to pipe in
    your input if you are going to use FTP. The only way to do that is to
    echo everything needed for FTP into a file and use that as redirected
    input..

    Olav.

    Dave Powell, MMfab wrote:

    >First off, FTP can't expand variables, but :echo can, so you need to build

    a
    >file (any old temp file is ok), and redirect FTP's input to it, more or

    less
    >like:
    >
    >!FILE FTPI = FTPI; REC=-72,,F,ASCII
    >!ECHO exitonerror >> *FTPI
    >!ECHO verbose >> *FTPI
    >!ECHO open whatever >> *FTPI
    >!ECHO user whoever>> *FTPI
    >!ECHO put !remotefile >> *FTPI
    >!ECHO quit >> *FTPI
    >!
    >!RUN FTP.ARPA.SYS < FTPI
    >!IF FTPLASTERR <> 0
    >! some error routine, etc
    >
    >This will also give you better error checking if anything goes wrong.
    >
    >Also, you dont need the 1st 4 setvars that just dummy-out the variables you
    >are going to set later.
    >
    >Also, it looks to me like your code would eat the leading zeros

    single-digits
    >months. Try the "rht" function like Keven said
    >
    >----- Original Message -----
    >From: "mag"
    >To:
    >Sent: Friday, November 30, 2007 13:58
    >Subject: [HP3000-L] variable question
    >
    >
    >hello,
    >
    >My file name,remotefile, is not coming out like I thought. I am trying to
    >name
    >the file "cntr" and concatenate the month and year to the file name. What

    I
    >am getting is this : "!file_name". Can you see what I am doing wrong?
    >Thanks!
    >
    >!setvar file_name ' '
    >!setvar remotefile ' '
    >!setvar mon ' '
    >!setvar yr ' '
    >!setvar mon '!hpmonth'
    >!setvar yr '!hpyear'
    >!setvar file_name 'CNTR!mon!yr'
    >!setvar remotefile "!file_name"
    >!COMMENT
    >
    >!FTP
    >OPEN
    >USER
    >!put !remotefile
    >


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


  8. Re: variable question

    Joshua,
    Thanks for the ideas.
    Something I failed to mention was that I may be trying to send up to 100 files in a run, so i dont want to be exiting ftp and restarting it every file...
    I am using : on the ftp internal commands to copy and purge cos that works,and I coulnt find any other way to execute local commands inside ftp.
    Will an ! also work there - will have to try that,

    or if I do


    !job xyx...
    !ftp
    user

    put x
    :copy x,y
    urge x
    put..

    exit
    !showvar ftp@
    !eoj


    will the :copy and urge commands be skipped by mpe , or not?

    I suspect I need to build a redirection file as input to ftp, and this willavoid the unwanted mpe execution.
    If I can avoid the need for intervention , I can just tell the users that if it fails , re-run it, dont call me unless it fails in a different mode......

    thanks,
    jp
    ________________________________________
    From: Joshua Johnson [bithead999@gmail.com]
    Sent: Sunday, 2 December 2007 5:38 PM
    To: John Pitman
    Subject: RE: [HP3000-L] variable question

    John,

    I need to see a $STDLIST to know for sure, but, I think the problem is that
    your job stream is executing the colon commands after FTP exits when it
    should be skipping them because they were meant to be input for FTP. MPE
    accepts both exclamation or colon as the first character in a job stream.
    For example the following two jobs are valid and will work exactly the same...
    I find most people only use ! rather than :.

    Colon job
    :job test,user.acct
    :showvar
    :eoj

    Exclamation job
    !job test,user.acct
    !showvar
    !eoj

    There are many ways to resolve your issue. Here one solution you could
    consider.

    1) Build an input file that is used when you call FTP. So inside your job
    you echo into a temp file the commands that you want FTP to execute then you
    !run ftp.arpa.sys;stdin=tempfile inside your job. Now those two commands
    will not be executed because they are inside the input file rather than in
    the job stream where MPE will be happy to execute them.

    2) Why put those two commands inside the FTP? Why not execute them after the
    FTP finishes and you know it was successful? Your pseudo code could look
    something like this.

    Build temp input file for FTP.ARPA.SYS. Echo exitonerror > tempfile, echo
    open remotenode >> tempfile, etc...
    Run ftp.arpa.sys;stdin=tempfile
    The above command:
    Sends file to transit dir
    Renames file from transit dir to processing dir
    Exits FTP
    If FTP success then (optional: if it fails on the rename you can call ftp
    again and delete the file you put in the transit dir)
    Copy local file to the sent directory
    Purge local file
    Else it failed so restream the job.
    Stream the job again in X number of minutes or whatever timeframe you
    want.
    Endif
    :EOJ

    Here is a somewhat complex method of building the ftp input file and
    checking for errors afterwards. You don't have to get this elaborate but, it
    gives you an idea of what I mean. Notice how I use :IF to check each FTP
    command and then set CI variables so I know what command failed. Then the
    ftp completes I display the output from FTP and check what command failed
    and take appropriate action. You job would likely just make sure it finished
    then execute your last two commands or restream the job if it failed. For
    this you can just use the FTPLASTERR and/or FTPLASTREPLY variables.

    # Create temporary file to used as STDIN on FTP run.
    if not _ft_ckstg
    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 ause 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.
    continue
    run ftp.arpa.sys;stdin=*!_ft_tmpin;stdlist=*!_ft_list
    if _ft_lastcmd<>'FINISH' or _ft_fail or _ft_verbose>0
    print !_ft_list;page=0
    endif
    endif

    # Check what command the transfer failed on and display message
    # and log the error to the FTP-LOG dataset.
    if _ft_lastcmd<>'FINISH' or _ft_fail or _ft_ckstg
    if not _ft_ckstg
    if _ft_lastcmd='OPEN' or (_ft_lastcmd='USER' and ftplasterr=-8)
    xeq !_ft_cmdmsg 13
    elseif _ft_lastcmd='USER' or _ft_failuser
    xeq !_ft_cmdmsg 14
    elseif _ft_lastcmd='CD' or _ft_failcd
    xeq !_ft_cmdmsg 15
    elseif _ft_lastcmd='PUTLC' or _ft_failputlc
    xeq !_ft_cmdmsg 16
    elseif _ft_lastcmd='REN' or _ft_failren
    xeq !_ft_cmdmsg 17
    elseif _ft_lastcmd='PUTCF' or _ft_failputcf
    xeq !_ft_cmdmsg 18
    endif
    endif

    Hope this helps!

    Josh

    -----Original Message-----
    From: John Pitman [mailto:jpitman@ryco.com.au]
    Sent: Saturday, December 01, 2007 11:45 PM
    To: Joshua Johnson
    Subject: RE: [HP3000-L] variable question

    I have an ftp application that build a job to do the work. FTP is started
    preceded by !continue and uses exitonerr, so that by doing a showvar all at
    the end I see the ftp variables to do with files sent etc

    the ftp logic is:=

    send file to a transit dir
    when put finished rename from transit to ready for processing dir
    copy local file to a sent directory
    purge local file

    these last 2 commands are inside FTP and are preceded by ':'


    When the link goes down while sending, ftp ends (exitonerror), and the next
    2 commands (those with get executed, then mpe gets an error on the next
    ftp command, and the job terminates. Then I have to copy the file moved to
    the sent dir back to working dir, build a new job to send remaining files
    and run it.

    Any way I can simplify this so it doesnt need manual intervention to restart
    it please...?

    tks
    john
    ________________________________________
    From: HP-3000 Systems Discussion [HP3000-L@RAVEN.UTC.EDU] On Behalf Of
    Joshua Johnson [bithead999@GMAIL.COM]
    Sent: Saturday, 1 December 2007 6:17 PM
    To: HP3000-L@RAVEN.UTC.EDU
    Subject: Re: [HP3000-L] variable question

    Hello,

    When using FTP I have found that if a transfer fails part way into the
    transfer then you end up with an incomplete file on the remote system. To
    avoid incomplete files being processed. I have used a temp file name to
    perform the initial PUT command, then when the PUT is complete I call REN to
    give the file it's intended name. If the transfer fails the REN will never
    happen and the receiver will know the transfer failed. If the remote file
    exists or may exist you can call DEL first then PUT/REN. You must call
    EXITONERROR before your DEL command so it won't exit if the file doesn't
    exist, then EXITONERROR again after the delete command to set the flag back...
    Another solution is to use a second confirmation file that could included
    the EOF and/or byte count of the data file. Another problem I had was not
    all errors caused FTP to exit when exitonerror was set (can't remember which
    ones, too long ago). To determine the exact error I would colon to MPE and
    set a variable before the command, then colon to MPE after the command and
    set appropriate variables if it failed (snip example below). The variable
    FTPLASTREPLY is very helpful along with FTPLASTERR. To make your $STDLIST
    cleaner you can redirect the FTP output to a file and only display it if an
    error occurred (run ftp.arpa.sys;stdin=*!_ft_tmpin;stdlist=*!_ft_list) .

    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

    Several years ago I wrote an application that was a front end for regular
    FTP. It stored the user/password/remote directory, etc information in a
    database accessed with a Cobol program. The rest was all CI script. It had
    different configs for production/test/development environments so you could
    move a job/program through environments without any code changes for remote
    hosts, it would know where it was and use the configs for that environment.
    It had a method to determine what FTP command failed and then if appropriate
    would stage the transfer and keep trying until the server became
    available/issue resolved (background job handled retries). It did the rename
    thing of course and if the rename failed it would re-connect and delete the
    temp file so it didn't clutter up remote servers. It could transfer a file
    to multiple hosts with one call to the app. Then only stage hosts that
    failed. Logging everything too of course. It would do GET and DIR on remote
    hosts also. I have all the code if anyone is interested in FTP on steroids.
    It has a Quick screen to put the configs into the database, but you could
    use Query or Suprtool.

    Joshua Johnson

    -----Original Message-----
    From: HP-3000 Systems Discussion [mailto:HP3000-L@RAVEN.UTC.EDU] On Behalf
    Of John Pitman
    Sent: Friday, November 30, 2007 10:03 PM
    To: HP3000-L@RAVEN.UTC.EDU
    Subject: Re: [HP3000-L] variable question

    I have found setting passive to help make the transfer less likely to time
    out on you. Uses a different no of ports or something.

    jp
    ________________________________________
    From: HP-3000 Systems Discussion [HP3000-L@RAVEN.UTC.EDU] On Behalf Of Olav
    Kappert [okappert@CANADA.COM]
    Sent: Saturday, 1 December 2007 12:55 PM
    To: HP3000-L@RAVEN.UTC.EDU
    Subject: Re: [HP3000-L] variable question

    Opps, I did not see the FTP. So Dave is right. You need to pipe in
    your input if you are going to use FTP. The only way to do that is to
    echo everything needed for FTP into a file and use that as redirected
    input..

    Olav.

    Dave Powell, MMfab wrote:

    >First off, FTP can't expand variables, but :echo can, so you need to build

    a
    >file (any old temp file is ok), and redirect FTP's input to it, more or

    less
    >like:
    >
    >!FILE FTPI = FTPI; REC=-72,,F,ASCII
    >!ECHO exitonerror >> *FTPI
    >!ECHO verbose >> *FTPI
    >!ECHO open whatever >> *FTPI
    >!ECHO user whoever>> *FTPI
    >!ECHO put !remotefile >> *FTPI
    >!ECHO quit >> *FTPI
    >!
    >!RUN FTP.ARPA.SYS < FTPI
    >!IF FTPLASTERR <> 0
    >! some error routine, etc
    >
    >This will also give you better error checking if anything goes wrong.
    >
    >Also, you dont need the 1st 4 setvars that just dummy-out the variables you
    >are going to set later.
    >
    >Also, it looks to me like your code would eat the leading zeros

    single-digits
    >months. Try the "rht" function like Keven said
    >
    >----- Original Message -----
    >From: "mag"
    >To:
    >Sent: Friday, November 30, 2007 13:58
    >Subject: [HP3000-L] variable question
    >
    >
    >hello,
    >
    >My file name,remotefile, is not coming out like I thought. I am trying to
    >name
    >the file "cntr" and concatenate the month and year to the file name. What

    I
    >am getting is this : "!file_name". Can you see what I am doing wrong?
    >Thanks!
    >
    >!setvar file_name ' '
    >!setvar remotefile ' '
    >!setvar mon ' '
    >!setvar yr ' '
    >!setvar mon '!hpmonth'
    >!setvar yr '!hpyear'
    >!setvar file_name 'CNTR!mon!yr'
    >!setvar remotefile "!file_name"
    >!COMMENT
    >
    >!FTP
    >OPEN
    >USER
    >!put !remotefile
    >


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

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


+ Reply to Thread