Buy commercial curl support. 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 Daniel himself.
Re: "--out-null"?
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Hans Henrik Bergan via curl-users <curl-users_at_lists.haxx.se>
Date: Wed, 17 Sep 2025 11:59:07 +0200
On Wed, Sep 17, 2025, 08:12 Bastian Jesuiter via curl-users <
curl-users_at_lists.haxx.se> wrote:
> Hi,
>
> Curl infers the name from the last path segment. (When you use the -O
> option)
>
> Combined with a head request, which will only return the response headers,
> but not the file (it's basically a get without response body), you should
> be able to print the url-effective or urle.path variable and parse it with
> awk.
>
> Alternatively, you can parse the head response where the
> content-disposition header is. To get the intended filename from the server.
> Curl would use the remote name if -J, --remote-header-name is being used.
>
> When using -o the filename is custom anyway. in this case you are probably
> using a script and will have the filename before submitting the curl
>
> Over all I think you should use a Head Request, which is explicitly
> designed for this purpose.
>
> Bastian
>
>
> On Wed, 17 Sept 2025, 01:18 Paul Gilmartin via curl-users, <
> curl-users_at_lists.haxx.se> wrote:
>
>> On 9/16/25 15:27, Paul Gilmartin via curl-users wrote:
>> >
>> > The following seems to transfer the entire 1.6 GB file,
>> > despite the "--out-null":
>> > ...
>> I stand corrected. I relied on my wishful thinking
>> rather than the man page. I had been wishing for a way
>> to use --write-out '%{filename_effective}' without
>> the expense of transferring a large file over the net.
>>
>> Is there a way? I had been using a read-only --output-dir
>> go get the filename_effective.
>>
>> --
>> Thanks,
>> gil
>>
>> --
>> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
>> Etiquette: https://curl.se/mail/etiquette.html
>>
> --
> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
> Etiquette: https://curl.se/mail/etiquette.h
> <https://curl.se/mail/etiquette.html>tml
I would use php-cli,
php -r 'echo basename(parse_url($argv[1])["path" ] );' 'url'
Unlike awk, php-cli properly understand curl-encoded filenames like %C3%A6
is "Æ" and it understands protocol,?query, #fragments, etc, awk does not,
and a naive implementation is likely to get edge cases wrong.
Date: Wed, 17 Sep 2025 11:59:07 +0200
On Wed, Sep 17, 2025, 08:12 Bastian Jesuiter via curl-users <
curl-users_at_lists.haxx.se> wrote:
> Hi,
>
> Curl infers the name from the last path segment. (When you use the -O
> option)
>
> Combined with a head request, which will only return the response headers,
> but not the file (it's basically a get without response body), you should
> be able to print the url-effective or urle.path variable and parse it with
> awk.
>
> Alternatively, you can parse the head response where the
> content-disposition header is. To get the intended filename from the server.
> Curl would use the remote name if -J, --remote-header-name is being used.
>
> When using -o the filename is custom anyway. in this case you are probably
> using a script and will have the filename before submitting the curl
>
> Over all I think you should use a Head Request, which is explicitly
> designed for this purpose.
>
> Bastian
>
>
> On Wed, 17 Sept 2025, 01:18 Paul Gilmartin via curl-users, <
> curl-users_at_lists.haxx.se> wrote:
>
>> On 9/16/25 15:27, Paul Gilmartin via curl-users wrote:
>> >
>> > The following seems to transfer the entire 1.6 GB file,
>> > despite the "--out-null":
>> > ...
>> I stand corrected. I relied on my wishful thinking
>> rather than the man page. I had been wishing for a way
>> to use --write-out '%{filename_effective}' without
>> the expense of transferring a large file over the net.
>>
>> Is there a way? I had been using a read-only --output-dir
>> go get the filename_effective.
>>
>> --
>> Thanks,
>> gil
>>
>> --
>> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
>> Etiquette: https://curl.se/mail/etiquette.html
>>
> --
> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
> Etiquette: https://curl.se/mail/etiquette.h
> <https://curl.se/mail/etiquette.html>tml
I would use php-cli,
php -r 'echo basename(parse_url($argv[1])["path" ] );' 'url'
Unlike awk, php-cli properly understand curl-encoded filenames like %C3%A6
is "Æ" and it understands protocol,?query, #fragments, etc, awk does not,
and a naive implementation is likely to get edge cases wrong.
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2025-09-17