Technical article 105125

Long lines in files transferred using cu(C)'s "~%put" command are corrupted.

OpenServer 5.0.0

Written · Last revised

Problem

cu(C) corrupts lines greater than 256 characters in length when sending files using the "~%put" command.

Cause

When cu(C) is told to transfer a file with "~%put", it spawns cat(C) on the remote machine to read the data being sent, and copy it to a file.

Usage of cat(C) means that cu(C) must configure the remote serial
driver to use canonical processing; the "icanon" mode as reported
by stty(C).  This allows cat(C) to detect when the end of the file
is reached. (It does this by converting the EOF (End Of File)
character into a 0 value return code, passed back to cat(C) by the
read(S) system call.)
When a serial line has "icanon" enabled, the line length is limited
to 256 bytes.  If a line is longer than this, only the characters
after the last multiple of 256 are output, causing the corruption
in the file on the remote system.

Solution

This problem cannot be avoided, and is a feature of the way cu(C) works.

To work around the problem, run uuencode(C) on the file before
sending it.  uuencode(C)'d files always have a maximum line
length of 62 characters, and would therefore not suffer from this
problem.  Use uudecode(C) to decode the file on the remote system.
This will also allow you to send binary files using cu(C).

However, you can (and in most cases should) use uucp(C) to send files to remote systems using serial/modem connections.

uucp(C) has many advantages over cu(C), which include:

In-built error correction Unattended file transfer Batching of file transfers Transfer of binary files (without prior encoding)

See also

cu(C) stty(C) termio(M) cat(C) read(S) uuencode(C) uudecode(C)

From the Xinuos technical article database, record 105125. Reproduced with permission. The original is at www.sco.com/ta/105125, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.