[Home]

Summary:ASTERISK-11133: v1.4.16.2 - Function STAT() returns 1 if file exists, blank if not found, should return zero
Reporter:dave cantera (dcantera)Labels:
Date Opened:2007-12-31 14:14:16.000-0600Date Closed:2007-12-31 14:30:06.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Functions/func_env
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:I found the function STAT() does not return a zero but returns a blank on the condition that a file does not exist.  
the conditional jump does  not fall through when no :, and when a label is entered, does not jump to the label, but still goes to the (1) true condition
see debugging info in add't info.


PS:  there is no category for Functions/func_stat()...


****** ADDITIONAL INFORMATION ******

dialplan excerpt:

exten => s,n,Set(TMPFILE=${SCREEN_FILE}.gsm)
exten => s,n,Set(FILE_EXISTS1=STAT(e,${SCREEN_FILE}.gsm))
exten => s,n,Set(FILE_EXISTS2=${STAT(e,${SCREEN_FILE}.gsm)})
exten => s,n,Set(FILE_EXISTS3=${STAT(e,${TMPFILE})})
exten => s,n,NoOp(FILE_EXISTS1=${FILE_EXISTS1})
exten => s,n,NoOp(FILE_EXISTS2=${FILE_EXISTS2})
exten => s,n,NoOp(FILE_EXISTS3=${FILE_EXISTS3})
exten => s,n,GotoIf(STAT(e,${SCREEN_FILE}.gsm)?Iknowthem:record-announcement)
exten => s,n(record-announcement),Swift(At the tone)
exten => s,n,Swift(Please tell me who is calling.)
;exten => s,n,Set(SCREEN_FILE=/tmp/${CALLERID(num)})
exten => s,n,Record(${SCREEN_FILE}.gsm|2|4)
exten => s,n,Goto(s,connect-call)
exten => s,n(Iknowthem),Playback(${SCREEN_FILE}|2|4)


CLI> excerpt (file does NOT exist):

   -- Executing [s@custom-screen:2] Swift("Zap/4-1", "Hello") in new stack
   -- Executing [s@custom-screen:3] Set("Zap/4-1", "SCREEN_FILE=/var/lib/asterisk/sounds/callerannounce/5202") in new stack
   -- Executing [s@custom-screen:4] Set("Zap/4-1", "TMPFILE=/var/lib/asterisk/sounds/callerannounce/5202.gsm") in new stack
   -- Executing [s@custom-screen:5] Set("Zap/4-1", "FILE_EXISTS1=STAT(e|/var/lib/asterisk/sounds/callerannounce/5202.gsm)") in new stack
   -- Executing [s@custom-screen:6] Set("Zap/4-1", "FILE_EXISTS2=") in new stack
   -- Executing [s@custom-screen:7] Set("Zap/4-1", "FILE_EXISTS3=") in new stack
   -- Executing [s@custom-screen:8] NoOp("Zap/4-1", "FILE_EXISTS1=STAT(e|/var/lib/asterisk/sounds/callerannounce/5202.gsm)") in new stack
   -- Executing [s@custom-screen:9] NoOp("Zap/4-1", "FILE_EXISTS2=") in new stack
   -- Executing [s@custom-screen:10] NoOp("Zap/4-1", "FILE_EXISTS3=") in new stack
   -- Executing [s@custom-screen:11] GotoIf("Zap/4-1", "STAT(e|/var/lib/asterisk/sounds/callerannounce/5202.gsm)?Iknowthem:record-announcement") in new stack
       -- Goto (custom-screen,s,16)
       -- Executing [s@custom-screen:16] Playback("Zap/4-1", "/var/lib/asterisk/sounds/callerannounce/5202|2|4") in new stack

CLI> excerpt (file does exist):

   -- Executing [s@custom-screen:3] Set("Zap/4-1", "SCREEN_FILE=/var/lib/asterisk/sounds/callerannounce/5202") in new stack
   -- Executing [s@custom-screen:4] Set("Zap/4-1", "TMPFILE=/var/lib/asterisk/sounds/callerannounce/5202.gsm") in new stack
   -- Executing [s@custom-screen:5] Set("Zap/4-1", "FILE_EXISTS1=STAT(e|/var/lib/asterisk/sounds/callerannounce/5202.gsm)") in new stack
   -- Executing [s@custom-screen:6] Set("Zap/4-1", "FILE_EXISTS2=1") in new stack
   -- Executing [s@custom-screen:7] Set("Zap/4-1", "FILE_EXISTS3=1") in new stack
   -- Executing [s@custom-screen:8] NoOp("Zap/4-1", "FILE_EXISTS1=STAT(e|/var/lib/asterisk/sounds/callerannounce/5202.gsm)") in new stack
   -- Executing [s@custom-screen:9] NoOp("Zap/4-1", "FILE_EXISTS2=1") in new stack
   -- Executing [s@custom-screen:10] NoOp("Zap/4-1", "FILE_EXISTS3=1") in new stack
   -- Executing [s@custom-screen:11] GotoIf("Zap/4-1", "STAT(e|/var/lib/asterisk/sounds/callerannounce/5202.gsm)?s|Iknowthem:s|record-announcement") in new stack
   -- Goto (custom-screen,s,16)
   -- Executing [s@custom-screen:16] Playback("Zap/4-1", "/var/lib/asterisk/sounds/callerannounce/5202|2|4") in new stack
   -- <Zap/4-1> Playing '/var/lib/asterisk/sounds/callerannounce/5202' (language 'en')

Comments:By: Digium Subversion (svnbot) 2007-12-31 14:23:54.000-0600

Repository: asterisk
Revision: 95470

U   branches/1.4/funcs/func_env.c

------------------------------------------------------------------------
r95470 | tilghman | 2007-12-31 14:23:52 -0600 (Mon, 31 Dec 2007) | 3 lines

Allow the default "0" to be returned if the STAT fails
(Closes issue ASTERISK-11133)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=95470

By: Digium Subversion (svnbot) 2007-12-31 14:30:06.000-0600

Repository: asterisk
Revision: 95490

_U  trunk/
U   trunk/funcs/func_env.c

------------------------------------------------------------------------
r95490 | tilghman | 2007-12-31 14:30:05 -0600 (Mon, 31 Dec 2007) | 11 lines

Merged revisions 95470 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r95470 | tilghman | 2007-12-31 14:27:26 -0600 (Mon, 31 Dec 2007) | 3 lines

Allow the default "0" to be returned if the STAT fails
(Closes issue ASTERISK-11133)

........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=95490