File Transfer between UNIX and DOS
HostAccess supports file transfer between the DOS PC and any UNIX host system. Installation of the host programs for these file transfer routines is documented below. Note that the UNIX system must have a C compiler available.
HostAccess also provides a suite of C programs that give access to the power of the Applications Interface. To obtain details of this program library, contact Perforce at Support-Hostaccess@perforce.com.
Two UNIX commands are provided to transfer data between UNIX and DOS
dosunix |
transfers data from a DOS file to a UNIX file. |
unixdos |
transfers data from a UNIX file to a DOS file. |
By default, the data is assumed to be textual. DOS records are mapped into a UNIX file structure, with CR/LF being replaced with LF and vice versa. This mapping can be overridden by the Binary option which performs no translation on the data.
During the transfer of data a window is displayed on the user screen showing the current state of the transfer and information such as the size of the file, the number of bytes transferred and the estimated time for the transfer. At the end of the transfer, the user is requested to press a key before the window is closed to allow time to read the final display.
You can fully control the two transfer commands from an application using the exec/system commands and all command line parameters may be passed, so avoiding the need for any user input.
Uploading the File Transfer Programs
The files DOSUNIX.C and UNIXDOS.C are supplied for the host file transfer programs. To install these onto your UNIX system, use the following instructions:
-
Copy DOSUNIX.C and UNIXDOS.C from the directory Unix on the floppy disk labeled "HOST PROGRAMS" into the HostAccess directory on your DOS hard disk.
-
Run HostAccess and logon to your UNIX system.
-
Enter the following UNIX command:
-
cat > dosunix.c
-
Select the System menu and select 'Start File Transfer'
-
The settings should be as follows :-
-
local file a:\unix\dosunix.c
-
protocol key
-
direction send
-
file type text
-
Click OK
-
The source code is then sent to the UNIX system. If you have problems you may have to slow down the upload process. Refer to Using HostAccess and Advanced HostAccess in the User guide for further details of configuring file transfer parameters. You should also turn off any host system case conversion on input.
-
When the upload has completed, press <CTRL> D to close the file.
-
Compile dosunix as follows:
-
cc dosunix.c -o dosunix
-
Now use the command dosunix to transfer unixdos.c by entering the following:
-
dosunix a:\\unix\\unixdos.c unixdos.c
-
Compile unixdos as follows:
-
cc unixdos.c -o unixdos
-
We suggest you copy the 2 programs to a suitable directory, e.g. /usr/bin.
-
You may need to alter the owner and rights of the program.
UNIX users may use the routines documented in this section to provide fast error-free file transfers between DOS and UNIX environments. These UNIX file transfer routines are written in portable 'C' and will need to be compiled on the host UNIX system.
Transferring From DOS to UNIX
To transfer data from DOS to UNIX, use the dosunix command. The transfer stops when the DOS end of file marker is found.
dosunix [-h -b -a -z -l -r -m [listfile]] dosfile unixfile
where dosfile is the name of the DOS file to be transferred, and unixfile is the name of the UNIX file (defaults to the DOS file name). If you omit the dosfile name, you are prompted for it.
For details of the options available with the dosunix command, see unixdos options.
Examples of DOS-UNIX File Transfer
To transfer a DOS file C:\WP\MAILSHOT.DOC to the Host UNIX file 'mail1.doc' , enter:
dosunix C:\\WP\\MAILSHOT.DOC mail1.doc
To transfer a DOS file C:\DOCS\BINARY in binary mode to a UNIX file called BINARY, enter:
dosunix -b C:\\DOCS\\BINARY
Transferring From UNIX to DOS
To transfer data from a UNIX file to a DOS file, use the unixdos command. If the DOS file exists, it will be overwritten, otherwise it will be created. By default a DOS end of file character will be written to the end of the DOS file.
Use the unixdos command as follows:
unixdos [-h -b -a -z -l -r] unixfile dosfile
where unixfile is the UNIX file to be transferred, and dosfile is the name of the DOS file (defaults to the UNIX file name). If you omit the unixfile name, you are prompted for it.
Examples of UNIX-DOS File Transfer
To transfer a UNIX file 'mail1.doc' to the DOS file C:\WP\MAILSHOT.DOC use the following command:
unixdos mail1.doc C:\\WP\\MAILSHOT.DOC
To transfer a UNIX file called BINARY to DOS in binary mode into the DOS file BINARY, use the following command:
File Transfer Options
The following options are available with both the dosunix and unixdos commands:
-a |
Append to the existing destination file. |
-b |
BINARY file specified - override mapping. With the dosunix command, no conversion of CRLF to LF is made, and the transfer does not stop when an end of file mark char(26) found. With the unixdos command, no conversion of LF to CRLF is made, and no end of file character is added to the DOS file. |
-h |
Initiated by host so transfer status window will not wait for user acknowledgment before closing and no status message will be printed to the screen. This option is useful for automated transfers carried out under host program control. An exit code of 0-6 is returned: 0: Successful Transfer 1: Aborted by the user 2: Unable to open DOS file 3: DOS file read error 4: Protocol Error 5: Retry Limit Reached 6: DOS file write error |
-z |
Suppress display of transfer status window. |
-l |
Local connection so use faster but less comprehensive error checking. LAN connections default to this mode. |
-r |
Remote connection so use full error checking. Asynchronous connections default to this mode. |
-m [listfile] |
Transfers the files listed in the host ASCII text file [listfile] to the host system. |
Examples of Multiple File Transfers
The following examples show how to use text files to control multiple file transfers:
Example 1: dosunix -m listfile
listfile contains three lines:
Line |
Line Contents |
Result |
---|---|---|
1 |
d: file1 |
file1 is transferred from the current working directory on the D drive on DOS to file1 in the current working directory on UNIX. |
2 |
d:\full path\file2 |
file2 is transferred from the specified DOS directory on the D drive on DOS to file2 in the current working directory on UNIX. |
3 |
d:\full path\file3 file 4 |
file3 is transferred from the specified DOS directory to file4 in the current working directory on UNIX. |
Example 2: unixdos -m listfile
listfile contains three lines as follows:
Line |
Line Contents |
Result |
---|---|---|
1 |
file1 |
file1 from the current working directory on UNIX is transferred to file1 in the TERMiTE directory. |
2 |
file2 d: |
file2 from the current working directory on UNIX is transferred to file2 in the current working directory on the D drive on DOS. |
3 |
file3 d:\full path\file 4 |
file3 from the current working directory on UNIX is transferred to file4 in the specified DOS directory. |