Point 5. Export to file. Then you can grab it by ftp out.
I tried and got all scripts in one big file in a format that is not friendly for the syntax highlighting in the various text editors (Atom, Sublime, Notepad++). I picked out one, see below.
What I'm looking for is to export each script in a individual file, preferably in a subdirectory (as that's way easier to sync over FTP: I love Beyond Compare for this) named as they are named in the WinBox script editor and in the same format as that script editor.
With those individual files, I should also be able to get them in a git repository easily.
I also want the other way around: have an updated file from the script repository, FTP it to the Mikrotik then install it.
Any ideas (especially as getting the individual script properties doesn't work, see below)?
I tried getting the script names, but it fails at the `:get`, indicating `bad command name get (line 1 column 114)`
:foreach scriptId in [/system script find] do={ :local script [/system script get $scriptId]; :local scriptName [:get $script name]; :put $scriptName }
bad command name get (line 1 column 114)
The `$script` variable holds each script with their properties, as this dumps all properties:
:foreach scriptId in [/system script find] do={ :local script [/system script get $scriptId]; :put $script }
Example of export (this is a fragment of `/system script export file=scripts.rsc`):
add name=Function.startsWithString.rsc owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source=":global startsWithString do={\r\
\n # returns true if \$value starts with \$subString\r\
\n\r\
\n#global varDump\r\
\n\r\
\n#:put \"value=\"\r\
\n#\$varDump value=\$value\r\
\n#:put \"subString=\"\r\
\n#\$varDump value=\$subString\r\
\n \r\
\n :local result false\r\
\n#:put \"result=\"\r\
\n#\$varDump value=\$result\r\
\n\r\
\n :if ([:typeof \$value] = \"str\") do={\r\
\n :if ([:typeof \$subString] = \"str\") do={\r\
\n :local valueLength [:len \$value]\r\
\n :local subStringLength [:len \$subString]\r\
\n :if (\$valueLength > \$subStringLength) do={\r\
\n# strings start at position zero (0)!\r\
\n# 01234\r\
\n# ABCDE -> length 5\r\
\n# AB -> length 2; positions 0..1\r\
\n\r\
\n :local valueStart (0)\r\
\n # bug that won't be fixed: :pick end parameter is 1-based, not 0-based http://forum.mikrotik.com/viewtopic.php\?t=108311\r\
\n # :local valueEnd (\$subStringLength - 1)\r\
\n :local valueEnd (\$subStringLength - 0)\r\
\n :local valuePick [:pick \$value \$valueStart \$valueEnd] \r\
\n#:put \"valueStart=\"\r\
\n#\$varDump value=\$valueStart\r\
\n#:put \"valueEnd=\"\r\
\n#\$varDump value=\$valueEnd\r\
\n#:put \"valuePick=\"\r\
\n#\$varDump value=\$valuePick \r\
\n :set \$result (\$subString = \$valuePick)\r\
\n }\r\
\n }\r\
\n };\r\
\n\r\
\n#:put \"result=\"\r\
\n#\$varDump value=\$result\r\
\n :return \$result;\r\
\n}\r\
\n\r\
\n# Examples:\r\
\n# /system script run Function.startsWithString.rsc\r\
\n# :put [\$startsWithString value=\"ABCDE\"]\r\
\n# false\r\
\n# :put [\$startsWithString value=\"ABCDE\" subString=(7)]\r\
\n# false\r\
\n# :put [\$startsWithString value=\"ABCDE\" subString=\"DE\"]\r\
\n# false\r\
\n# :put [\$startsWithString value=\"ABCDE\" subString=\"AB\"]\r\
\n# true\r\
\n"
--jeroen