How to execute CMD level commands using FTP client - akin to Windows OS built in FTP service

0 votes
asked Nov 19 by muellerk (120 points)

Hello,

We are using Windows batch scripts to execute FTPcommands on an FTP server with Windows FTP

Example command: "ftp -s:C:\test\UploadScript.SCP ftp.site.com"), which specifies a text file of ftp commands to automatically run after ftp starts.

The UploadScript.SCP has commands like:
bin
lcd "S:\Temp"
get /ftpsitefolder/filetoget.txt "S:\Temp\filetoget.txt"
bye

How can I utilize the FTP client in Rebex to issue custom commands such as 'lcd' on the remote server? lcd is changing the current working directory to a network share drive. However, that is not a built-in FTP command.

Applies to: Rebex FTP/SSL

1 Answer

0 votes
answered Nov 19 by Lukas Pokorny (104,230 points)

Actually, most of Windows FTP commands (and Unix FTP commands)do not directly correspond to actual FTP protocol commands. For example, 'bin' corresponds to "TYPE I", 'get' corresponds to a sequence of "PORT" / "RETR" commands, 'bye' corresponds to "QUIT", and 'lcd' is a local-only command that is not even send to the server (which knows nothing about S:\Temp and the structure of client's file system and its network share drives).

So I guess what you need is to implement an FTP client based on Rebex FTP/SSL that is more-or-less compatible with Windows FTP. Our FtpConsoleClient sample (available with our Rebex FTP/SSL install package) is quite close and implements the following commands:

!         disconnect   rmdir       rmtree
?         exit         user        auth
ascii     help         chmod       ccc
active    ls           get
binary    mkdir        put
bye       open         getr
cd        passive      putr
close     pwd          putdir
dir       quit         getdir

Extending it to be able to execute scripts and adding commands like 'lcd' or 'lpwd' should be quite simple - use: Directory.SetCurrentDirectory(path) for 'lcd';
Directory.GetCurrentDirectory() for 'lpwd'.

...