Question

I've got an FTPS site that I need to transfer a file to each night. My problem is that the site is hosted at a contractor's site (Contractor A) and the SSIS package that sends the file to the site was created/maintained by a another contractor (Contractor B).

My problem is that the file transfer isn't happening. Each of my contractors is blaming the other for the problem and it's left to me to determine the problem. Contractor B says that his SSIS package works only during the day while testing, but can not connect at night when it needs to. Contractor A claims that there is nothing changing with the FTPS site that would cause that.

I can create a .NET service to do this, but was hoping for a simplier solution. I was going to create a windows task that would execute a bat file every 5 minutes, and use the MS ftp client. However, I can't get this to work with the FTPS. I also couldn't get the User Name and PW sent with the url. Any help here would be appreciated. I've been on Google all morning and have found multiple examples that almost work, but nothing that gets me all the way there.

Any simple command line test that uses Explicit FTP over TLS and allows passing a user name and pw is all that is needed.

Was it helpful?

Solution

To periodically check if the service can be reached a simple telnet would be enough. You don't even have to speak ftp. If you really want to upload a file, then the simpliest would be to use an ftp command line client used by a script. The script can be in whatever language, it does not matter.

It might also be worth exploring the checktls service. It allows to test tls connections, you can click together a list of commands. In this case classical ftp commands like 'USER: someone' and 'PASS: somepass' and so on.


The Filezilla client offers to specify the usage of explicit or implicit tls. From the description at the FileZilla Wiki:

Explicit vs Implicit FTPS

FTPS (SSL/TLS) is served up in two incompatible modes. If using explicit FTPS, the client connects to the normal FTP port and explicitly switches into secure (SSL/TLS) mode with "AUTH TLS", whereas implicit FTPS is an older style service that assumes SSL/TLS mode right from the start of the connection (and normally listens on TCP port 990, rather than 21). In a FileZilla client this means prefixing the host with "FTPES://" to connect an "explicit" FTPS server, or "FTPS://" for the legacy "implicit" server (for which you will likely also need to set the port to 990).


And here is a cURL pased solution using phps cURL extension:

// $handle: the file to upload
$handle  = fopen ( $path, 'r' );
// $url: the ftps url to connect to (without credentials)
$url     = sprintf ( 'ftps://%s/%s', $server, $filename ); 
// the ftp connection
$session = curl_init ( ); 
// connection details
curl_setopt ( $curl_session, CURLOPT_URL, $url );
curl_setopt ( $curl_session, CURLOPT_USERPWD, sprintf( '%s:%s', $user, $pass );
curl_setopt ( $curl_session, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt ( $curl_session, CURLOPT_SSL_VERIFYHOST, FALSE );
curl_setopt ( $curl_session, CURLOPT_FTP_SSL, CURLFTPSSL_TRY );
curl_setopt ( $curl_session, CURLOPT_FTPSSLAUTH, CURLFTPAUTH_TLS );
curl_setopt ( $curl_session, CURLOPT_UPLOAD, 1 );
curl_setopt ( $curl_session, CURLOPT_INFILE, $handle );
// execute the connection
$output = curl_exec  ( $session );
// check for errors
$error  = curl_errno ( $session );
// close connection
curl_close ( $session );

The advantage of this approach: you can automate it. For example call it as a cron job.

OTHER TIPS

WinSCP is scriptable, even for FTPS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top