HI,
The script below creates the file but it is empty. I would like the results to be saved on the file aside from just showing on the terminal. Is that possible?
:foreach i in=[ /ip/hotspot/user print file=aaaaaaaaaaa detail as-value where comment=admin ] do={:put ((“username: " . $i->“name”) .” " . "password: " . ($i->“password”));}
username: 649c8 password: 26927
username: dexsm password: 46789
username: 4btjb password: 93555
username: ua67a password: 97954
username: t5w6n password: 65495
username: rr2wm password: 25265
username: kwmd3 password: 73223
username: 9yexa password: 43636
username: bnkxv password: 84966
username: xrmpb password: 88595
yes, is possible but your script can’t do that.
use this:
:global filecontent ""
/file print file="userexport.txt"
:delay 1s
/ip hotspot user
:foreach i in=[find where comment="admin"] do={
:set filecontent ($filecontent."username: ".[get $i name]." password: ".[get $i password]."\r\n")
:put ("username: ".[get $i name]." password: ".[get $i password])
}
/file set "userexport.txt" contents=$filecontent
remove this line (or comment with # at start of line) for not display on terminal but only save on file.
:put ("username: ".[get $i name]." password: ".[get $i password])
/file set “userexport.txt” contents=$filecontent
enclosing the filename into double-quotes completed the code.
Thank you very much!!!
Thanks, I add the forgetted "