When you develop an on-box JUNOS automation, you may need to store some data locally so it can be accessed later by a subsequent instance of your script, a completely different JUNOS automation, or even a remote application. You have several options for persisting and accessing your data on JUNOS, each with its own set of strengths, weaknesses and consequences.
You can find overviews, pros and cons, and "gotchas" for each approach by reading:
Any way to add an USB as a persistent storage to extend on-box storage?
I've gone back to this post multiple times as a reference for storing variables in slax. Excellent reference.