login | register
Thu 04 of Dec, 2008 [02:31 UTC]

voip-info.org

Discuss [1] History

Asterisk func stat

Created by: murf,Last modification on Sat 03 of Feb, 2007 [08:11 UTC] by perepo

Synopsis:

 Does a check on the specified file (NEW in Asterisk 1.4)

Description:

 STAT(<flag>,<filename>)
 
flag may be one of the following:
  • d: Checks if the file is a directory
  • e: Checks if the file exists
  • f: Checks if the file is a regular file
  • m: Returns the file mode (in octal)
  • s: Returns the size (in bytes) of the file
  • A: Returns the epoch at which the file was last accessed
  • C: Returns the epoch at which the inode was last changed
  • M: Returns the epoch at which the file was last modified


Notes

  • *CLI> show function STAT

Return value

Returns the resulting string.

Example

exten => s,1,Set(foo=${STAT(s,/var/t3)})


See also



Comments

Comments Filter
222

333usage with comparison operator

by baji, Saturday 28 of June, 2008 [22:39:16 UTC]
.
when STAT() is used in an expression inside a GotoIf, you can get the wrong result if you do a string comparison of a numeric return value.

So take a numeric return value, make sure it is non-zero and then use it in a comparison expression.

Eg. 2 > 1 is TRUE but "2" > "100000000" is also true

See below

exten => s,1,Set(filexist=${STAT(e,path-to-sound-file.ul)})
exten => s,n,Set(filesize=${STAT(s,path-to-sound-file.ul)})
exten => s,n,Set(filesize=$[${filesize} + 1])
exten => s,n,GotoIf($["${filexist}" = "1" & ${filesize} > 1]?use_sound:use_default)