[Asterisk-Users] Proper syntax for the "Cut" application?

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Mon Nov 3 12:17:37 MST 2003


On Monday 03 November 2003 12:13, Steven Sokol wrote:
> Hi.  I am looking for the proper syntax for the Cut application.  I
> am working on a "Feature Code" extension that drops a caller
> directly into a voicemail box.  Here is what I have:
>
> exten => _55.,1,Answer()
> exten => _55.,2,Cut(VMEXT=EXTEN|55|2)

Here's your first problem.  Cut uses a single character to separate
fields.  So the delimiter is '5' and the second field is indeed empty.

> exten => _55.,3,Voicemail(u${VMEXT})
> exten => _55.,4,Hangup()
>
> When I dial 551100, the system tries to process this but I get
> dropped immediately.  Here is the output:
>
> -- Executing Answer("SIP/ppc-6aa2", "") in new stack
> -- Executing Cut("SIP/ppc-6aa2", "VMEXT=EXTEN|55|2") in new stack
> -- Executing Voicemail("SIP/ppc-6aa2", "u") in new stack
> == Parsing '/etc/asterisk/voicemail.conf': Found
> WARNING[1234379840]: File app_voicemail.c, Line 836
> (leave_voicemail): No entry in voicemail config file for ''
>
> Obviously the new variable VMEXT is empty.  Why is that?  I read
> the source for app_cut.c and the syntax looks correct.  I am asking
> for the second field which should be '1100'.  I have tried several
> versions of this, including changing the line from: exten =>
> _55.,2,Cut(VMEXT=EXTEN|55|2) to: exten =>
> _55.,2,Cut(VMEXT=${EXTEN}|55|2)

There is a far simpler syntax for doing what you're doing, which is
fixed string parsing.  Cut() is intended to be used when fixed won't
work (i.e. variable width before the delimiter).  Instead, use
${EXTEN:2}.

-Tilghman




More information about the asterisk-users mailing list