Where is it printing this error when you run it in a script?
Are you declaring the global variable within the script? This does not change the variable value, but is necessary to access the variable ( http://forum.mikrotik.com/t/script-text-runs-on-terminal-but-not-from-run-script/61673/1)
:global systemIdent
/log info "$systemIdent"