Reputation:
I want to get the latest libre office from their ftp using wget. However, I can not figure out in the BIG documentation where they mention you can select the latest updated directory.
This is the ftp I want to access:
http://ftp.nluug.nl/office/libreoffice/libreoffice/stable/5.0.1/win/x86_64/
However, after libreoffice/stable I don't want to specify this type but I want wget to automatically select the latest updated directory. Does anyone know how to do that?
I thought, maybe I could do this:
http://ftp.nluug.nl/office/libreoffice/libreoffice/stable/*/win/x86_64/
But that would make no sense. I tried finding it on stackoverflow, google and wget documentation, but I haven't found it. I appreciate it if you help me!
If you have any questions, just comment :)
INFO: I download it using a batch file
Upvotes: 0
Views: 98
Reputation: 73746
Let's access the distro site via ftp
protocol and use wget
in debug mode to get the last directory:
DIRECTORY; perms 755; size: 66; month: Jul; day: 30; time: 11:36:00 (no yr); 4.4.5
DIRECTORY; perms 755; size: 66; month: Aug; day: 5; time: 09:59:00 (no yr); 5.0.0
DIRECTORY; perms 755; size: 66; month: Aug; day: 27; time: 14:06:00 (no yr); 5.0.1
Assuming the ftp server listing is sorted by date, or unsorted, or while the major version is below 10, we can simply grab the last line without analyzing the date:
@echo off
set "BASEURL=ftp://ftp.nluug.nl/pub/office/libreoffice/libreoffice/stable/"
for /f "delims=; tokens=1,7" %%a in (
'wget --debug %BASEURL% --spider 2^>^&1'
) do if "%%a"=="DIRECTORY" if not "%%b"=="" (
rem trim spaces
for /f "tokens=*" %%c in ("%%b") do set lastversion=%%c
)
wget %BASEURL%%lastversion%/win/x86_64/*
pause
Upvotes: 1