# CLI Rules for Datatex Software

**URL:** <https://discourse.datatex.co.za/t/cli-rules-for-datatex-software/102>\
**Category:** Voice recording ( Amethyst and iReCall )\
**Tags:** amethyst, voip\
**Created:** [October 12, 2021, 3:47pm UTC](https://discourse.datatex.co.za/t/cli-rules-for-datatex-software/102 "2021-10-12T15:47:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeonvanHeerden](https://discourse.datatex.co.za/letter_avatar_proxy/v4/letter/l/51bf81/32.png) [@LeonvanHeerden](https://discourse.datatex.co.za/u/LeonvanHeerden)\
**Post date:** [October 12, 2021, 3:47pm UTC](https://discourse.datatex.co.za/t/cli-rules-for-datatex-software/102/1 "2021-10-12T15:47:43Z")

</div>

The CLI Rules are used to to manipulate the call data of call recordings or TMS data.  
Applicaitons that has this facility:

- tngbuffer
- amtmitel
- crecallinfo
- amtmitelcre
- amtmitelcre2
- siprecord
- voipsweeper
- convert\_recordings2

CLI rules consist of the following parts and delimited by a PIPE character ( “|” )

1. Field to check
2. Type of match
3. Value1 to look for
4. Action
5. Value2
6. Stop
7. Direction

1. **Field to check** - This field to be matched. The rule can only have one field to check. Values are:  
`EXTENSION` - match on extension  
`NUMBER` - match on number  
`TRUNK` - match on trunk  
`USERNAME` - Match on the username field was added to newer versions of the software. `Siprecorder` \>= `1.7.6.0`

2. **Type of match** - How the rule will find the records to change  
`STARTS WITH` - match if the field starts with value1  
`ENDS WITH` - match if the field ends with value1  
`CONTAINS` - match if the field contains value1  
`DOES NOT CONTAIN` - match if the field does not contain value1  
`ALWAYS MATCH` - rules with this type of match execute for every record  
`LENGTH GREATER THAN` - if the field length is greater than value1 - value1 is a number in the range 0 to 255. If the field contains multiple values, each will trigger this rule.  
`LGT` - short for LENGTH GREATER THAN  
`LENGTH LESS THAN` - if the field length is less than value1 - value1 is a number in the range 0 to 255  
`LLT` - short for LENGTH LESS THAN

3. **Value1** to look for - what is matched or not matched or the length, depending on the type of match. You can’t look for the `VALUE="|"` since it is the delimiter in the CLIRule.

4. **Action** what to do when the Value1 Matches  
`IGNORE` - makes no modifications - you can use ignore with action “STOP” set to “TRUE” to do nothing and stop other rules from processing.  
`REPLACE WITH` - replaces the matched value with value2.  
`REPLACEWITH` - same as “REPLACE WITH”  
`REPLACEALL` - replaces all occurrences of value1 with value2, usually used with match “CONTAINS” or “ALWAYS MATCH”  
`REPLACEFIELD` - replaces the entire field with value2.  
`DELETE` - removes the matched value (value2 is not used).  
`DELETECOUNT` - deletes x number of characters starting at the matched position. value2 is the number x.  
`DELETEALL` - clears the entire field (value2 is not used) - same as REPLACEFIELD with nothing in value2.  
`DELETEBEFORE` - deletes x characters before the match. Value2 is the number x. x can be larger than the number of characters before the match. For example, a rule to delete 8 characters before the hash from “01234#0215924033” would delete only the first 5 before the hash. Note that the # would be left in the field. DELETECOUNT is the corresponding DELETEAFTER action – use “DELETECOUNT” and not “DELETEAFTER”.  
`ADD TO START` - adds value2 in front of the field. Note that the matched position does not matter.  
`ADD TO END` - adds value2 after the field. Note that the matched position does not matter.  
`DELETERECORD` - instructs the software to delete this record. Usually the software will log this.  
`REJECT` - instructs the software to reject this record. Usually the software will log this.  
`PREFIX` - same as ADD TO START, but the value prefixed can be from a lookup table if value2 = “”. Value1 will be used as the key to the lookup, and the result from the lookup will be prefixed to the field.

5. **Value2** - what to use as replacement / add / count / prefix / suffix. You can’t use the `VALUE="|"` since it is the delimiter in the CLIRule.

6. **Stop** - If TRUE, when this rule matches, the rules after this will not process. Values can be:  
`TRUE` → Stop processing rules here.  
`FALSE` → Continue processing rules.

7. **Direction** - will only match records that have the matching direction. Values can be:  
`INCOMING`  
`OUTGOING`  
`ANY`

**Examples**

`0=EXTENSION|STARTS WITH|27319293700|REPLACE WITH|0319293700|TRUE|ANY|`  
If the extension started with “27319293700” , replace those digits with “0319293700”. Stop processing rules here if this rules triggers.

1=EXTENSION|STARTS WITH|319293700|REPLACE WITH|0319293700|TRUE|ANY|  
If the Extenions starts with “319293700” replace those digits with “0319293700”. Do not process any further rules if this rule triggers.

2=Number|starts with|00|REPLACE|0|False|OUTGOING|

3=Extension|length less than|3|reject||False|ANY|

4=Extension|length greater than|5|reject||False|ANY|

5=Extension|starts with|\*|reject||False|ANY|

6=Extension|starts with|0|reject||False|ANY|
