[comp.protocols.tcp-ip] Summary- FTP c callable functions

abair@oakhill.UUCP (Alan Bair) (02/21/89)

I would like to thank everyone that responded to my request for help with
FTP.  Sorry I was not able to respond directly to everyone that sent me
suggestions.  And for those that wanted to know what I learned, here is a
summary of the suggestions.

First off, always read ALL of the man page. It turned out that toward the
end, in the section 'FILE NAMING CONVENTIONS', most of what other people
had to say was described.  However, the examples made it a lot easier to
understand.

1. Using the filename '-' for the local file in a put or get will cause
	FTP to read from stdin or write to stdout.  Here is an example
	from rpw3@amdcad.UUCP (Rob Warnock):
-----------------------------------------------------------------------------
Try this (setting $HOST, $USER, $PASS, and $DESTFILE as needed):

        $ cmd... | (echo $USER; echo $PASS; echo put - $DESTFILE) | ftp $HOST

and the output of "cmd..." should end up in $DESTFILE on $HOST. Same thing
works to retrieve output from a remote site:

        $ (echo $USER; echo $PASS; echo get $DESTFILE - ) | ftp $HOST | cmd...

with the remote file showing up as the standard input of "cmd...".

In fact, with some care, binary files usually work, too, but you may run into
problems with error messages ending up in the stream sometimes, etc.
----------------------------------------------------------------------------
	This example also demonstrates the piping of commands to FTP, so you
	could run it in a shell or in C with system("...") without user
	input.

2. The local filename can also be '|program ..." which will cause FTP to either
	read stdout of the program in a put or write to stdin of the program
	in a get.  Here is an example from "Stuart Levy" 
	<uc.msc.umn.edu!slevy@cs.utexas.edu>:
----------------------------------------------------------------------------
ftp>  put "|shellcommand  args ..."  remote-file

and

ftp>  get  remote-file  "|shellcommand  args ..."

so if you can stand to call the pipeline from inside FTP, you can
have it read/write on pipelines rather than disk files.
----------------------------------------------------------------------------
	This also gets around the problem of messages possibly ending up in
	the data stream, as Rob mentioned above.  He also mentioned, that
	due to security reasons, this generally is not allowed for the
	remote filename.

3. I also had an offer for source code that was C callable and acted like
	one end of the FTP connection.  However, it turned out that there
	were some legal requirements(paperwork) to allow for the transfer.
	If your interested, contact:
	hermes.chpc.utexas.edu!xxss533@cs.utexas.edu (Kenneth J. Montgomery)

I think a combination of options 1 and 2 should do what I was looking for.
One final point that I failed to make in my first request, the machine at
the other end of the FTP connection is an IBM mainframe running the
Fibronnics KNET software.  So some of the suggetions I received would not
have worked, along with some of the above options for the remote filename.

Again, Thanks for all the help.
It makes you wonder what the world would be like without a net.

Alan Bair
UUCP cs.utexas.edu!oakhill!turbinia!abair

rjh@cs.purdue.EDU (Bob Hathaway) (02/25/89)

Does anyone know of a way to pipe command output?  I'd like to do
something simple like "ls | more", but nothing seems to work.

Thanks,
Bob Hathaway
rjh@purdue.edu