...
Examples:
Read mode (byte):;reads
Code Block |
---|
title | Example: Reads the entire content of the file |
---|
|
...
|
same => n,Set(foo=${FILE(/tmp/test.txt)}) |
...
Code Block |
---|
title | Example: Reads from the 11th byte to the end of the file (i.e. skips the first 10) |
---|
|
...
|
same => n,Set(foo=${FILE(/tmp/test.txt,10)}) |
...
Code Block |
---|
title | Example: Reads from the 11th to 20th byte in the file (i.e. skip the first 10, then read 10 bytes) |
---|
|
...
|
same => n,Set(foo=${FILE(/tmp/test.txt,10,10)})
|
Read mode (line):; reads
Code Block |
---|
title | Example: Reads the 3rd line of the file |
---|
|
...
|
same => n,Set(foo=${FILE(/tmp/test.txt,3,1,l)}) |
...
Code Block |
---|
title | Example: Reads the 3rd and 4th lines of the file |
---|
|
...
|
same => n,Set(foo=${FILE(/tmp/test.txt,3,2,l)}) |
...
Code Block |
---|
title | Example: Reads from the third line to the end of the file |
---|
|
...
|
same => n,Set(foo=${FILE(/tmp/test.txt,3,,l)}) |
...
Code Block |
---|
title | Example: Reads the last three lines of the file |
---|
|
...
|
same => n,Set(foo=${FILE(/tmp/test.txt,-3,,l)}) |
...
Code Block |
---|
title | Example: Reads the 3rd line of a DOS-formatted file |
---|
|
...
|
same => n,Set(foo=${FILE(/tmp/test.txt,3,1,l,d)})
|
Write mode (byte):; truncate
Code Block |
---|
title | Example: Truncate the file and write |
---|
|
...
...
|
same => n,Set(FILE(/tmp/test.txt)=bar) |
...
; Append "bar"
Code Block |
---|
title | Example: Append bar |
---|
linenumbers | true |
---|
|
same => n,Set(FILE(/tmp/test.txt,,,a)=bar) |
...
Code Block |
---|
title | Example: Replace the first byte with |
---|
|
...
...
(replaces 1 character with 3) | linenumbers | true |
---|
|
same => n,Set(FILE(/tmp/test.txt,0,1)=bar) |
...
Code Block |
---|
title | Example: Replace 10 bytes beginning at the 21st byte of the file with |
---|
|
...
...
|
same => n,Set(FILE(/tmp/test.txt,20,10)=bar) |
...
Code Block |
---|
title | Example: Replace all bytes from the 21st with |
---|
|
...
...
|
same => n,Set(FILE(/tmp/test.txt,20)=bar) |
...
Code Block |
---|
title | Example: Insert bar after the 4th character |
---|
linenumbers | true |
---|
|
same => n,Set(FILE(/tmp/test.txt,4,0)=bar)
|
Write mode (line):;
Code Block |
---|
title | Example: Replace the first line of the file with |
---|
|
...
...
|
same => n,Set(FILE(/tmp/foo.txt,0,1,l)=bar) |
...
Code Block |
---|
title | Example: Replace the last line of the file with |
---|
|
...
...
|
same => n,Set(FILE(/tmp/foo.txt,-1,,l)=bar) |
...
Code Block |
---|
title | Example: Append bar to the file with a newline |
---|
linenumbers | true |
---|
|
same => n,Set(FILE(/tmp/foo.txt,,,al)=bar)
|
Info |
---|
|
If live_dangerously in asterisk.conf is set to no , this function can only be executed from the dialplan, and not directly from external protocols. |
...
This documentation was imported from Asterisk Version GIT-19-56f9c28a506436d82