0 votes
by (250 points)

Is it possible to bind an FTP client session to the Terminal control the same way you would a telnet or SSH session for user interaction? In other words, rather than using the Windows "Console" as the interface for an FTP session I want to use the Terminal control so that I can script and record the FTP session. With SSH I would do:

private Ssh ssh = new Ssh();

and for telnet:

private Telnet telnet = new Telnet(hostname, port);

but when I try to do this:

private Ftp ftp = new Ftp();

I get an error.

Error CS1503 Argument 1: cannot convert from 'Rebex.TerminalEmulation.FileTransfers' to 'Rebex.TerminalEmulation.IShellChannelFactory'

Is there a way to do this?

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (69.8k points)

No, it is not possible. Actually, it wouldn't work as you are probably expecting.

Please note that FTP protocol is very specific. It uses control connection, which can be used in plain Telnet. And for file uploads, downloads and directory listing the FTP protocol uses data connection. For each transfer, new data connection is established.

If you bind the Terminal control to well configured Telnet, you can script control connection. But you wouldn't be possible to create data connections. Which means you wouldn't be able to transfer any file or list directories.

You can try it like this:

var telnet = new Telnet("test.rebex.net", 21);
terminal.Options.NewLineSequence = NewLineSequence.CRLF;
terminal.Options.LocalEcho = true;

Then type:

USER demo
PASS password

I suppose that you basically want to script classic "Console" ftp command line application such as MSFTP. Am I right?

This could be possible if you write your own IShellChannelFactory respectively ShellChannel to transport data.