Any Way Of Creating A File To Write To From The Dialplan, Or Must I Use AGI?
Home » Asterisk Users » Any Way Of Creating A File To Write To From The Dialplan, Or Must I Use AGI?
Seems I can write to an existing file, but is there really no way of creating a new file to log some data to, without reverting to AGI?
(will be different for each caller ID)
6 thoughts on - Any Way Of Creating A File To Write To From The Dialplan, Or Must I Use AGI?
Won’t the system command do it?
Yes, that would also work (thanks!).
It just seems a bit hacky – STAT…GotoIf… System..,Return…FILE….
Has there been any previous discussion as to why FILE can’t/won’t create a file and write to it in one shot?
If so, what was the outcome? Should I suggest it?
Thanks!
I’m able to use the FILE function to create files just fine.
Set(FILE(${CALLFILE},,,al,u)=Extension: s)
That’s just what I’m using, John.
But I’m getting (eg)
[Nov 4 21:46:16] ERROR[1676][C-00000003]: func_env.c:449 file2format:
Cannot open ‘/home/logs/anonymous.txt’: No such file or directory
[Nov 4 21:46:16] ERROR[1676][C-00000003]: func_env.c:949 file_write:
File ‘/home/logs/anonymous.txt’ not in line format
Asterisk is running as root (yeah, I know!), and has permissions on that directory. Hmmm….
Could it be SELinux blocking you?
If you change the path to /tmp does it work?
Ugh. Thanks, John.
I took another look at your example, and saw that you had a ,u at the end.
So, even though that supposedly only specifies the line format, it also seems to act as “create if not exist”.
Problem solved – thanks! I’ll add that to my ever lengthening list of Asterisk tips/gotchas!