After reading the link provided by my friend below, I can understand what you're saying now.
Oh, finally you understand and now I can help you without brainless cut-and-paste
some code
{
:local filename "history_users_and_passwords.txt"
:local pppoeArr [/interface pppoe-client print detail as-value]
:local addThis ""
:foreach item in=$pppoeArr do={
:set addThis ($addThis."Password for user >$($item->"user")< is >$($item->"password")<\r\n")
}
/file
:if ([:len [find where name="flash" and type="disk"]] = 1) do={:set filename "flash/$filename"}
:if ([:len [find where name=$filename]] = 0) do={print file="$filename"; :delay 4s; set $filename contents=""}
:delay 2s
:local filecontent [get $filename contents]
:local newfilecontent "$filecontent$addThis"
set $filename contents=$newfilecontent
}
But it would be better if you explained exactly what you need:
Do you lose your password when the device turns off???
Probably you just need one "export" for backup all the RouterBARD configuration, and save it elsewhere.