pipe to ftp broken
David J. Camp
david at wubios.wustl.edu
Thu Aug 31 15:28:51 AEST 1989
Since I originally sent this inquiry, I have determined that the problem
is with piping a file to ftp. I compiled the ftp from the tahoe
collection, and that does the same thing. I have changed my script to
generate a temporary file and ftp that, but it would be nice if this
problem could be fixed. -David-
Bitnet: david at wubios.wustl ^ Mr. David J. Camp
Internet: david%wubios at wucs1.wustl.edu < * > Box 8067, Biostatistics
uucp: uunet!wucs1!wubios!david v 660 South Euclid
Washington University (314) 36-23635 Saint Louis, MO 63110
>From spots at rice.edu Wed Aug 30 11:59:31 1989
Received: from rice.edu by wubios.WUstl.EDU (4.0/Sun UNIX 4.0); Wed, 30 Aug 89 11:59:25 CDT
Received: from titan.rice.edu by rice.edu (AA24777); Wed, 30 Aug 89 11:52:07 CDT
Received: from eos.rice.edu.0 by titan.rice.edu (AA22622); Wed, 30 Aug 89 11:52:09 CDT
Date: Wed, 30 Aug 89 11:52:09 CDT
From: Sun-Spots Digest <spots at rice.edu>
Message-Id: <8908301652.AA22622 at titan.rice.edu>
To: david at wubios
Subject: sun-spots submission
Status: OR
i received your sun-spots submission (listed below) - but
since it is not SUN specific - it does not belong in the
sun-spots digest..
vicky
__________________________________________________
------------------------------
Subject: ftp from pipe broken
Date: Fri, 25 Aug 89 5:39:04 CDT
From: david at wubios.wustl.edu (David J. Camp)
I am trying to write a shell script that will accept a file on the
stdin, and ftp it to a file on a remote host. It requires that the
username and password be specified in the .netrc file. The necessary
ftp commands are written to a temporary file, and combined with the
stdin by cat. I find that when I am transferring a certain 1.6MB binary file,
the transfer aborts prematurely, and it attempts to read the rest of the
file as ftp commands. This of course gives me a series of ?Invalid
command messages, and the resulting file is corrupt. Any help would be
appreciated. -David-
----- start of fileput -----
#! /bin/csh
set host=$1
set file=$2
set mode=$3
set extra=$4
if ("$file" == "" || "$extra" != "") then
echo usage\: ftpput host file \[mode\] \< local-file
echo place an entry in \~/.netrc like this:
echo
echo machine HOST-NAME login USER-NAME password PASSWORD
echo
echo for each host with which you need to communicate
echo and type \'chmod 600 \~/.netrc\'
echo the mode can be ascii binary or tenex, ascii is the default
exit 2
endif
set MKSTEMP=`mkstemp /tmp/pt`
echo open $host >> $MKSTEMP
echo $mode >> $MKSTEMP
echo put - $file >> $MKSTEMP
/usr/bin/cat $MKSTEMP - | /usr/local/bin/ftp -vd
/bin/rm -f $MKSTEMP
----- start of mkstemp.c -----
/* mktemp.c -- program to generate a unique file name */
#include <stdio.h>
#include <string.h>
char * mktemp ();
main (argc, argv)
int argc;
char * argv [];
{
char filename [256];
if (argc != 2)
{
fprintf (stderr, "usage: mktemp prefix\n");
fprintf (stderr, "returns to stdout a unique file from the ");
fprintf (stderr, "template: prefixXXXXXX\n");
exit (2);
}
strcpy (filename, argv [1]);
strcat (filename, "XXXXXX");
mkstemp (filename);
fprintf (stdout, filename);
exit (0);
}
--
Bitnet: david at wubios.wustl ^ Mr. David J. Camp
Internet: david%wubios at wucs1.wustl.edu < * > Box 8067, Biostatistics
uucp: uunet!wucs1!wubios!david v 660 South Euclid
Washington University (314) 36-23635 Saint Louis, MO 63110
More information about the Comp.unix.questions
mailing list