Copy a File to an Existing IBM i File

Copy a File to an Existing IBM i File

These examples copy, in text mode, one sequential file to another. This is the simplest form of data transfer.

LIB File System

1 set _echo=yes
2 set _halton=warn
3 open unix=sol9 user=top098 pwd=p100m
4 cd unix=/opt/app/data
5 mode type=text
6 copy unix=data10.txt local=MYLIB/APPDATA(DAILY)
7 quit 


For this first IBM i example, the following is a line-by-line explanation:

  1. Line 1 turns on command echo, which results in each command being sent to stdout prior to processing.
  2. Line 2 sets the error condition value on which script processing halts. Any error greater than or equal to warn halts script processing.
  3. Line 3 opens a session between the local UDM Manager and a remote UDM server running on host sol9. The host sol9 is given the logical name of unix. The open command also provides user credentials for the UDM server to verify and, if successfully verified, specifies the user ID with which the UDM server executes.
  4. Line 4 changes the current directory of the UDM server unix running on host sol9.
  5. Line 5 changes the transfer mode type from binary (the default) to text. Text mode transfers will translate between code pages (for example, ASCII and EBCDIC) and process the end-of-line characters.
  6. Line 6 is the copy command that actually moves the data between systems. It copies file data10.txt on server unix to the local UDM Manager library: MYLIB Data Physical File APPDATA member DAILY.
  7. Line 7 executes the quit command, which closes all sessions and exits UDM with the highest exit code set.

HFS File System

1 set _echo=yes
2 set _halton=warn
3 open unix=sol9 user=top098 pwd=p100m
4 filesys local=hfs 
5 cd unix=/opt/app/data
6 mode type=text
7 attrib local createop=replace
8 copy unix=data10.txt local=/opt/appdata
9 quit


This HFS file system example is basically the same as the LIB file system example, with these changes:

  • Addition of line 4, which changes the local file system from the default of LIB to HFS. The file system type dictates the syntax and semantics of file specifications, such as in the copy command.
  • Addition of line 7, which sets the local attribute createop. createop controls how a file is created. By default, its value is new, which indicates that only new files are created and existing files are not written over (replaced). In this case, its value is being set to replace, specifying that if the file exists, it should be replaced; otherwise, it is created.

Components

Universal Data Mover Manager for IBM i