Using System V `cu'.

Tony Olekshy tony at oha.UUCP
Tue Nov 29 02:02:26 AEST 1988


In <6808 at venera.isi.edu>, Stuart Cracraft (cracraft at venera.isi.edu) writes:
>
> How do you slow down cu's file transfer capability (e.g. the tilde-put
> command)?

Easy.  Write a trivial.c program to putc(getc()) till EOF on argv[1].  After
each putchar of a \n, sleep(1).  Then use ~$trivial send_file.  Now ~%put also
adds a "cat > send_file" before your data, ^D at end, and fiddles stty to
prevent tab expansion (or something like that).  Below is a version I use to
send files to VMS with ~$tovms.  Blend on high for a few minutes, and you're
on your way.

/*  This routine, run with the cu(1) ~$ escape copies its argument files
    (default stdin) to VMS.

    Options:	The default is to copy the files to stdout, ie, to whatever
		is reading from the terminal on the VMS side.

	-c fnm	Run from a DCL prompt, this COPYs the argument files into
		the VMS file named fnm.

	-f	Run from a DCL prompt, with a single file name argument,
		this option creates a VMS file with the same name as the
		tail of the argument file name.  The -f option, if used,
		must be the last option before the file name argument.
									*/

#define	nap(t) (sleep((int)(t / 1000)))	/* If you don't have nap().	*/

#include <stdio.h>
#include <string.h>

extern	int	 errno;
extern	char	*sys_errlist[];

static	char	*outFile = NULL;

main(argc, argv) int argc; char *argv[];
{
    int		 argi;
    FILE	*fd;
    int		 c;
    int		 copyCMD=0;
    char	*p;

    for (argi = 1; argi < argc; argi += 1) {

	if (argv[argi][0] != '-') /* Not an option. */		break;

	if (!argv[argi][1] || argv[argi][2]) {

	    fprintf(stderr, "%s: bad option \"%s\".\n", *argv, argv[argi]);
	    exit (1);
	    }

	if (argv[argi][1] == 'c') {

	    if (++argi >= argc) {

		fprintf(stderr, "%s: missing -c option value.\n", *argv);
		exit (1);
		}

	    outFile = argv[argi];				continue;
	    }

	if (argv[argi][1] == 'f') {

	    if (argi+1 >= argc) {

		fprintf(stderr,
		    "%s: missing file name for -f option.\n", *argv);
		exit (1);
		}

	    outFile = argv[argi+1];

	    if ((p = strrchr(outFile, '/')) != NULL) outFile = p+1;

	    continue;
	    }

	fprintf(stderr, "%s: unknow option \"%s\".\n", *argv, argv[argi]);
	exit (1);
	}

    /* Process files (default stdin). */

    setbuf(stdout, NULL);

    do {

	if (argi >= argc) fd = stdin;

	else {
	    if ((fd = fopen(argv[argi], "r")) == 0) {

		fprintf(stderr, "%s: can't open \"%s\", %s.\n",
		    *argv, argv[argi], sys_errlist[errno]);	continue;
		}
	    }
	
	if (outFile != NULL && !copyCMD) {

	    if (strchr(outFile, '.') == NULL) {

		fprintf(stderr, "%s: output file \"%s\" must contain a \".\"\n",
		    *argv, outFile);
		exit (1);
		}

	    printf("COPY SYS$INPUT %s\r\n", outFile);	nap(1000L);

	    copyCMD = 1;
	    }

	while ((c = getc(fd)) != EOF) {

	    putchar((c == '\n') ? '\r' : c);

	    if (c == '\n') { putchar(c); nap(1000L); }
	    }

	fclose(fd);

	} while (++argi < argc);

    if (copyCMD) printf("%c", 032);	/* ^Z terminates COPY */

    exit (0);
    }



More information about the Comp.unix.wizards mailing list