How to download a file from the web in ScriptFTP

29th December 2016
ScriptFTP has commands to retrieve files from FTP sites only but it can also download files from the web (HTTP/HTTPS) using an external tool like CURL. You can download it going to this page. The Windows version of CURL is almost at the bottom of that page.
Once you have downloaded it you need to place curl.exe in any folder and call it from ScriptFTP using the EXEC command this way:
# Set the current local directory
LOCALCHDIR("C:\Users\Carlos\Desktop\curl_downloaded_files")
 
# Call curl
EXEC("C:\path_to\curl\curl.exe -O https://www.mydomain.com/thefile.zip")
If you browse the CURL website or run “curl.exe –help” you will notice the big amount of options and switches it has. It is a very versatile tool that not only downloads file from websites, it is also capable of automating form filling, HTTP authentication etc. For example, if the web browser prompts to enter an user name and password you can tell curl to login this way:
# Download a file using HTTP authentication
EXEC("C:\path_to\curl\curl.exe --user johndoe:thepswd -O https://www.mydomain.com/thefile.zip")
Note that HTTP authentication is not the kind of authentication you commonly find when going to web sites like yahoo mail, gmail etc. These are just HTML forms. You can identify HTTP authentication when the browser asks for the login in a very spartan pop-up window on top of the web browser.

read more …

Tags


Handling file dates and time spans

13th December 2016

The ScriptFTP scripting language does not have data types (as most scripting languages) and dealing with anything which is not plain text requires some kind of tricks. This happens with file lists as we have seen before, dates and time spans suffer the same limitation. This post covers how these data types are handled in ScriptFTP.

read more …