Asterisk FILE function query

Hi all,

Does anyone know about any possible limitations with the FILE function?
what i’d like to do is use it to write a line (CDR) when i hangup a call.
Problem is, i’m getting advice to watch out for problems regarding “file locks” or “threading” issues, which, put simply, stops a program from writing to it constantly if it’s currently in use on another call that’s writing to it (so you can’t write twice in the same moment).

I know i can use the CDR or CEL function in asterisk, however i’m looking for something that i can embed in the dialplan and make something pretty exotic with.

I’m using the file function like this (below), which appends a newline to the txt file when called

If anyone knows if this isn’t a problem, that’d be awesome.
Thanks in advance

you may have problem when file gets big . Why dont you use DataBase for your customized CDR ?

Irrespective of my lack of understandig of Your goal there’s a way to avoid concurrent writes to a file using FILE-function within the asterisk dialplan.
Just have a closer look at functions LOCK and UNLOCK.

For Unix to guarantee that file writes won’t get interleaved, you must open the file in append mode and you must use the system call level (write) rather than the C level (fwrite) functions to do the write. Alternatively you must lock the file between open and close. Even if FILE now supports being used for writes, I don’t think it will do enough of these to gurantee you won’t get output interleaved.

I would use the System application with an external program, or use AGI. In both cases, one needs to make sure that the file is written in a suitable way.

Sounds like the way forward is for me to write some Python or Java to get the job done. And call it using AGI.
Most likely I’ll write to the file, then check it’s contents to ensure there’s a line with what should be in there.

might be that I’ll create a FILE sub to be called appropriately by the “h” extension, and throw thousands of calls at the system in the space of an hour and see if it misses anything, then perhaps thousands of calls in a few minutes…I’d like to use FILE as it’s less complex.