# Interactively parsing eSIM Activation from LPA in QRCode...

**URL:** <https://forum.mikrotik.com/t/interactively-parsing-esim-activation-from-lpa-in-qrcode/182146>\
**Category:** Scripting\
**Created:** [February 21, 2025, 7:36pm UTC](https://forum.mikrotik.com/t/interactively-parsing-esim-activation-from-lpa-in-qrcode/182146 "2025-02-21T19:36:54Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Amm0](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/amm0/32/1630_2.png) [@Amm0](https://forum.mikrotik.com/u/Amm0)\
**Post date:** [February 21, 2025, 7:36pm UTC](https://forum.mikrotik.com/t/interactively-parsing-esim-activation-from-lpa-in-qrcode/182146/1 "2025-02-21T19:36:54Z")

</div>

In 7.18, there are new eSIM commands & new serialize/deserialize fixes. While I have no idea what modems or hardware supports them. But from a discussion in another thread about eSIM support, I cleaned the example to using “ask” to prompt for the needed information.  
:global activateEsimFromQr do={  
:local samplelpa “LPA:1$EXAMPLE.COM$XYZ123$$1$$”  
:local qrlpa [/terminal/ask “eSIM activation code (decoded from QR):” preinput=$samplelpa]  
:local activationcode  
:local parsedlpa ([:deserialize from=dsv delimiter=“$” $qrlpa options=dsv.plain]-\>0)  
:if ([:len $parsedlpa]\<3) do={ :error “ERROR - invalid eSIM activation code” }  
:put “\tparsed:”  
:put [:serialize to=json $parsedlpa options=json.pretty]  
:if (($parsedlpa-\>4) = 1) do={  
:set activationcode [/terminal/ask “Confirmation Code Required (provided by eSIM carrier):”]  
:put “The esim provision (no confirmation code required) command should be:”  
:put “/interface/lte/esim/provision interface=[find] sm-dp-plus="$($parsedlpa-\>1)" matching-id="$($parsedlpa-\>2)" confirmation-code="$activationcode"”  
} else={  
:put “The esim provision with confirmation code command should be:”  
:put “/interface/lte/esim/provision interface=[find] sm-dp-plus="$($parsedlpa-\>1)" matching-id="$($parsedlpa-\>2)"”  
}  
}

> [amm0@bigdude] \> $activateEsimFromQr  
> eSIM activation code (decoded from QR):  
> LPA:1$EXAMPLE.COM$XYZ123$$1$$  
> parsed:  
> [  
> “LPA:1”,  
> “[EXAMPLE.COM](http://EXAMPLE.COM)”,  
> “XYZ123”,  
> “”,  
> 1,  
> “”,  
> “”  
> ]  
> Confirmation Code Required (provided by eSIM carrier):  
> jhjhkhd  
> The esim provision (no confirmation code required) command should be:  
> /interface/lte/esim/provision interface=[find] sm-dp-plus=“[EXAMPLE.COM](http://EXAMPLE.COM)” matching-id=“XYZ123” confirmation-code=“jhjhkhd”  
> [amm0@bigdude] \> $activateEsimFromQr  
> eSIM activation code (decoded from QR):  
> LPA:1$EXAMPLE.COM$XYZ123$  
> parsed:  
> [  
> “LPA:1”,  
> “[EXAMPLE.COM](http://EXAMPLE.COM)”,  
> “XYZ123”,  
> “”  
> ]  
> The esim provision with confirmation code command should be:  
> /interface/lte/esim/provision interface=[find] sm-dp-plus=“[EXAMPLE.COM](http://EXAMPLE.COM)” matching-id=“XYZ123”

Now what modem support those commands, IDK. And annoyed about that part. But the [:serialize] / [:deserialize] / [/terminal/ask] do make quick work of the, theoretical, problem — especially using a CLI with strings that contain $ — which eSIM activations do. i.e. “LPA:1$example.com$abc$123”, and the spec uses a dollar sign $ as a separator, instead of a , comma or something normal.

---

_[View the full topic](https://forum.mikrotik.com/t/interactively-parsing-esim-activation-from-lpa-in-qrcode/182146)._
