Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

transferFile

&pagelevel(3)&pagelevel

You use transferFile to perform a file transfer. transferFile starts the file transfer and waits inside ftscript for the end of the file transfer.
The file transfer itself can be restarted.

If you specify remoteSuccessScript (see section “remoteSuccessScript”) or remoteFailureScript (see section “remoteFailureScript”) then the corresponding script is subsequently run on the remote computer.
For local scripts, you should use faulthandlers (see section “faulthandler”) or executeScript (see section “executeScript”). For an example, see "transferFile".

Types of file transfer

You use transferFile to transfer files as follows:

  • File transfers from "remote" to "local" (fromRemoteFile toLocalFile)

  • File transfers from "local" to "remote" (fromLocalFile toRemoteFile)

  • File transfers from "remote" to "remote" can be accomplished by means of two sequential transferFile activities, e.g in a sequence activity:

    • File transfer from "remote" to "localTmp"
      (fromRemoteFile toLocalTmpFile)

    • File transfer from "localTmp" to "remote"
      (fromLocalTmpFile toRemoteFile)

Restrictions

  1. After de-referencing, fromRemoteFile and toRemoteFile must possess a partner specification.

  2. The elements fromLocalFile and toLocalFile must not possess any partner specification after de-referencing.

  3. You cannot use transferFile to perform any file transfers from "local" to "local".

    To perform file transfers from "local" to "local", you must use a corresponding script (copy) or specify one of the two files as "remote" and specify the local computer as the partner (specify transferAdmission).

Format

 <transferFile compress?="none|byteRep|zip" writeMode?=  
 "replace|new|extend" transparentMode?="true|false"
 dataEncryption?="yes|no|onlyDataIntegrity">
   comment?
   context?
   ( (fromRemoteFile   toLocalFile)    |
     (fromLocalFile    toRemoteFile)   |
     (fromRemoteFile   toLocalTmpFile) |
     (fromLocalTmpFile toRemoteFile)  )
   remoteSuccessScript?
   remoteFailureScript?
 </transferFile>

Attributes

Name

Value

Meaning

compress?

none | byteRep | zip

The default value is none. The file is not compressed.
If byteRep is specified then identical sequences of characters are compressed. If zip is specified then
zip compression is used.

writeMode?

replace | new |

extend

The default value is replace. If the file exists then it is overwritten. If the file does not exist, it is created.
If extend is specified then the data is appended to the existing file. If the file does not exist, it is created.
If new is specified then a new file is created. If a file with this name already exists then the activity is cancelled with the error ft_exist.

transparentMode?

true | false

The default value is false. The file is transferred as standard.
If true is specified then a transparent transfer is performed (e.g. in the case of transfers from a BS2000 system to another BS2000 system via a Windows/Unix system).

dataEncryption?

yes | no |

onlyDataIntegrity

The default value is no.
The user data is not encrypted.
If yes is specified then the user data is encrypted (for settings see the manual "openFT (Unix and Windows systems) - Command Interface").
If onlyDataIntegrity is specified then only the data integrity is checked.

Examples

1. File transfer with remoteSuccessScript / remoteFailureScript

 <?xml version="1.0" encoding="UTF-8"?>
 <ftscript version="1">
   <context>
     <script id="everything ok">
       <unixScript><![CDATA[echo everything ok
            >frg_eis_15/status.txt]]>
       </unixScript>
       <windowsScript>
          <![CDATA[cmd /c "echo everything ok"
            >frg_eis_15\status.txt]]>
       </windowsScript>
     </script>
     <script id="something failed">
       <unixScript><![CDATA[echo something failed>
            frg_eis_15/status.txt]]>
       </unixScript>
       <windowsScript>
          <![CDATA[cmd /c echo something failed
            >frg_eis_15\status.txt]]>
       </windowsScript>
     </script>
     <partner id="remote" name="UnixP_1" systemType="unix">   
       <transferAdmission>
         <ftacAdmission ftacAdmission="FTACADM1"/>
       </transferAdmission>
     </partner>
   </context>
   <sequence>
     <context>
       <faulthandler>
         <default>
           <executeScript ref="something failed"/>
         </default>
       </faulthandler>
     </context>
     <transferFile>
       <fromRemoteFile name="bin.mp3">
         <partner ref="remote"/>
         <directory name="frg_eis_15"/>
       </fromRemoteFile>
       <toLocalFile name="bin.mp3">
         <directory name="frg_eis_15"/>
       </toLocalFile>
       <remoteSuccessScript ref="everything ok"/>
       <remoteFailureScript ref="something failed"/>
     </transferFile
  <executeScript ref="everything ok"/>
   </sequence>
 <transferFile writeMode="extend">
     <fromRemoteFile name="status.txt" data="char">
       <partner ref="remote"/>
       <directory name="frg_eis_15"/>
     </fromRemoteFile>
     <toLocalFile name="status.txt">
       <directory name="frg_eis_15"/>
     </toLocalFile>
   </transferFile>
 </ftscript>


The file bin.mp3 is transferred from the partner remote to the local file bin.mp3. The file status.txt is then created with the following contents:

  • if transfer is OK

everything ok
everything ok

  • if an error occurs

something failed
something failed

If errors occur during the compilation of the file status.txt then the script is aborted.

2. File transfer from "remote" to "remote"

 <?xml version="1.0" encoding="UTF-8"?>
 <ftscript version="1">
   <context>
     <partner id="remote1" name="UnixP_1">
       <transferAdmission>
         <ftacAdmission ftacAdmission="FTACADM1"/>
       </transferAdmission>
     </partner>
     <partner id="remote2" name="WindowsP_1">
       <transferAdmission>
         <ftacAdmission ftacAdmission="FTACADM2"/>
       </transferAdmission>
     </partner>
   </context>
   <transferFile>
     <fromRemoteFile name="data.txt">
       <partner ref="remote1"/>
       <directory name="frg_eis_16"/>
     <autoDataSpec charPattern="*.txt" binPattern="*.dat *.mp3"/>   
     </fromRemoteFile>
     <toLocalTmpFile id="tmp"/>
   </transferFile>
   <transferFile>
     <fromLocalTmpFile use="tmp"/>
     <toRemoteFile name="data.txt">
       <partner ref="remote2"/>
       <directory name="frg_eis_16"/>
     </toRemoteFile>
   </transferFile>
 </ftscript>

In the example, the file data.txt is first copied from the partner remote1 to a temporary file. The temporary file is given an internal name. The suffix of the temporary file corresponds to the suffix of the associated fromRemoteFile (here *.txt).

Conversion is performed using autoDataSpec charPattern for character symbols because the filename suffix corresponds to the pattern .txt (see section “autoDataSpec”). If the local system is a Windows system then the line ends are converted accordingly.

When the temporary file is transferred to the remote system remote2, the autoDataSpec settings made when the temporary file was created are taken over. They are inherited as well as maxRecSize and the data properties of the fromRemoteFile element. If the local system is a Windows system then the data is not converted on the second transfer. In the case of a local Unix system, the reverse would be true. When the transfer to the local system is performed, no data is converted. Instead, the data is converted on the subsequent transfer to the remote system.

3. Use of faulthandler and executeScript for local scripts

faulthandler (see section “faulthandler”) corresponds to the localFailureScript, and the executeScript, which directly follows transferFile (see section “executeScript”) corresponds to the localSuccessScript.

You can activate a transferFile request with local*Script as indicated in the example below:

 ...
 <sequence>
   <context>
    <faulthandler>
       <default>
         <executeScript>
           .... localFailureScript...
         </executeScript>
       </default>
    </faulthandler>
   </context>
   <transferFile>
   .... 
   </transferFile>
   <executeScript>
   ... localSuccessScript...
   </executeScript>
 <sequence>
 ...

This sequence can also be located in a parallel or foreach - parallel statement.