cURL / Mailing Lists / curl-users / Single Mail


Re: reading a log file while open

From: Ray Satiro via curl-users <>
Date: Fri, 22 Apr 2016 15:25:42 -0400

On 4/22/2016 2:17 AM, Daniel Stenberg wrote:
> On Fri, 22 Apr 2016, Francisco Gonzalez Velasco wrote:
>> C:\>curl -o c:\q\events.txt -k -H "Authorization: Bearer
>> My_Authorization" ""
>> I need to read the contents of the events.txt file while the cURL
>> process is still active.
>> Is this possible?
> That's not curl making it hard, that's Windows for you. Any other
> operating system would let you read the file while another process is
> writing to it...
> So, you need to consider a work-around. Maybe pipe curl's output into
> your programs stdin isntead? Or maybe consider using libcurl and get
> the data downloaded directly within your application?

It's likely not that he can't read the file but instead he reads the
file and it doesn't have the latest information due to buffering.

Francisco try --no-buffer [1][2] which should help. A program like
Notepad++ will detect when the file is updated and should offer to
reload it.

Also instead as Leif mentioned you could use tee to write the output to
the console and append it to a file at the same time. You can find tee
for Windows in gnuwin32 build of coreutils [3]. Extract tee.exe,
libintl3.dll and libiconv2.dll from the bin dir in and Then you pipe curl
to tee, tee writes to the file but also outputs to the console:

curl --silent --no-buffer -H "Authorization: Bearer My_Authorization" | tee --append c:\q\events.txt

And I suggest you don't use the -k switch, when you do that you're
disabling the certificate check. If there's a certificate problem
correct it!


List admin:
Received on 2016-04-22