Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if file exists on FTPS site using cURL

Tags:

file

curl

exists

I am using the cURL app to download multiple csv files. I want to find a way to check if the file exists on the ftps site before kicking off the download. If it doesn't exist I would like to find a way for cURL to check again at regular intervals. I am trying to stick to using cURL commands for this I am really not good at .Net programming. Any help would be appreciated


1 Answers

$ curl ftp://[host]/[path] --ssl --head

(you might also need -k)

--ssl: Try to use SSL/TLS for the connection

--head: When used on an FTP or FILE file, curl displays the file size and last modification time only

It will return an error if the file doesn't exist. It will not keep checking, it will only check once so you need to do the repeated checking using some scheduler/cron/script or whatever.

like image 98
Daniel Stenberg Avatar answered Feb 03 '26 06:02

Daniel Stenberg