Buy commercial curl support from
WolfSSL. We help you work out your issues, debug your libcurl
applications, use the API, port to new platforms, add new features and more.
With a team lead by the curl founder himself.
Re: How can I just get the output name?
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: ToddAndMargo via curl-users <curl-users_at_lists.haxx.se>
Date: Tue, 26 Mar 2024 15:36:36 -0700
On 3/26/24 15:28, ToddAndMargo via curl-users wrote:
> On 3/26/24 09:10, Dan Fandrich via curl-users wrote:
>> On Tue, Mar 26, 2024 at 07:18:21AM -0700, ToddAndMargo via curl-users
>> wrote:
>>> On 3/24/24 05:41, ToddAndMargo via curl-users wrote:
>>>> Firefox CliGet gives me this when I click on a particular
>>>> download link:
>>>>
>>>> curl --header 'Host: dl.duosecurity.com'
>>>> ...
>>>> 'https://dl.duosecurity.com/duo-win-login-latest.exe'
>>>> --output 'duo-win-login-4.3.0.exe'
>>>>
>>>> All I want is the "duo-win-login-4.3.0.exe" text.
>>>> Using cURL, is there a way to get?
>>
>> This will do it:
>>
>> curl -sI -o /dev/null --write-out '%header{content-disposition}\n' \
>> https://dl.duosecurity.com/duo-win-login-latest.exe | \
>> sed -e 's/^.*="//' -e 's/".*$//'
>>
>> This requests only the headers from the site and writes out just the
>> Content-Disposition: header, then strips off everything that's outside
>> quotation marks. You'd want a more robust header parser if you want to
>> work it
>> to work reliably with any file name on any site, but it's likely good
>> enough
>> for this one URL. You'll need a curl version at least 7.83.0 to get
>> the %header
>> feature.
>>
>> Dan
>
> Hi Dan,
>
> Awesome!
>
> $ curl -sI -o /dev/null --write-out '%header{content-disposition}\n'
> https://dl.duosecurity.com/duo-win-login-latest.exe
> attachment; filename="duo-win-login-4.3.0.exe"
>
> $ curl -sI -o /dev/null --write-out '%header{content-disposition}\n'
> https://dl.duosecurity.com/duo-win-login-latest.exe | sed -e 's/^.*="//'
> -e 's/".*$//'
> duo-win-login-4.3.0.exe
>
> Thank you!
>
> -T
Since I will be processing it in Raku (Perl6);
$ curl -sI -o /dev/null --write-out '%header{content-disposition}\n'
https://dl.duosecurity.com/duo-win-login-latest.exe | perl6 -e 'my
$x=get(); $x~~s:i/ ".exe".* //; $x~~s:i/ .* "-" //; say $x'
4.3.0
Date: Tue, 26 Mar 2024 15:36:36 -0700
On 3/26/24 15:28, ToddAndMargo via curl-users wrote:
> On 3/26/24 09:10, Dan Fandrich via curl-users wrote:
>> On Tue, Mar 26, 2024 at 07:18:21AM -0700, ToddAndMargo via curl-users
>> wrote:
>>> On 3/24/24 05:41, ToddAndMargo via curl-users wrote:
>>>> Firefox CliGet gives me this when I click on a particular
>>>> download link:
>>>>
>>>> curl --header 'Host: dl.duosecurity.com'
>>>> ...
>>>> 'https://dl.duosecurity.com/duo-win-login-latest.exe'
>>>> --output 'duo-win-login-4.3.0.exe'
>>>>
>>>> All I want is the "duo-win-login-4.3.0.exe" text.
>>>> Using cURL, is there a way to get?
>>
>> This will do it:
>>
>> curl -sI -o /dev/null --write-out '%header{content-disposition}\n' \
>> https://dl.duosecurity.com/duo-win-login-latest.exe | \
>> sed -e 's/^.*="//' -e 's/".*$//'
>>
>> This requests only the headers from the site and writes out just the
>> Content-Disposition: header, then strips off everything that's outside
>> quotation marks. You'd want a more robust header parser if you want to
>> work it
>> to work reliably with any file name on any site, but it's likely good
>> enough
>> for this one URL. You'll need a curl version at least 7.83.0 to get
>> the %header
>> feature.
>>
>> Dan
>
> Hi Dan,
>
> Awesome!
>
> $ curl -sI -o /dev/null --write-out '%header{content-disposition}\n'
> https://dl.duosecurity.com/duo-win-login-latest.exe
> attachment; filename="duo-win-login-4.3.0.exe"
>
> $ curl -sI -o /dev/null --write-out '%header{content-disposition}\n'
> https://dl.duosecurity.com/duo-win-login-latest.exe | sed -e 's/^.*="//'
> -e 's/".*$//'
> duo-win-login-4.3.0.exe
>
> Thank you!
>
> -T
Since I will be processing it in Raku (Perl6);
$ curl -sI -o /dev/null --write-out '%header{content-disposition}\n'
https://dl.duosecurity.com/duo-win-login-latest.exe | perl6 -e 'my
$x=get(); $x~~s:i/ ".exe".* //; $x~~s:i/ .* "-" //; say $x'
4.3.0
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A computer without Microsoft is like a chocolate cake without the mustard ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2024-03-26