Page 1 of 1

strange problem importing rsc script

Posted: Wed Feb 17, 2016 3:10 pm
by tslytsly
Hi all,

I have been designing a simple program that generates a script file to be imported in to a fully reset (i.e. no defaults) Mikrotik router.

However when I try to import the rsc file generated by the program I get this error:
expected command name (line 1 column 1)
I don't know why, when I copy the text of the RSC file and paste it into the terminal window it's fine, but if I try and import it I get the error.

Here are the first few lines of text in the rsc:
:log info "**** Starting auto-setup script ****"

:log info "Configuring log to file..."
/system logging
	action add target=disk name=ScriptLog disk-file-name=ScriptLog disk-file-count=1  
	add action=ScriptLog topics=script
	


:log info "Creating bridge interface..."
/interface bridge
add arp=proxy-arp name=bridge-LAN

It throws the error on the first Char!

Here is the output of an import verbose=yes command:
#line 1
▒▒▒:log info "**** Starting auto-setup script ****"
expected command name (line 1 column 1)
What are those characters before :log?

Any help gratefully appreciated.

tslytsly

Re: strange problem importing rsc script

Posted: Wed Feb 17, 2016 3:16 pm
by BartoszP
They could be spaces, tabs or other nonvisible characters as "hardspace" or ... you have edited and copied script as UTF-8 file and then strange chars come from UTF coding.

My advice: Copy scripts from Winbox to "stupid" NotePad and then look for nonstandard characters. Remove them and copy the script back .

Re: strange problem importing rsc script

Posted: Wed Feb 17, 2016 4:11 pm
by tslytsly
They could be spaces, tabs or other nonvisible characters as "hardspace" or ... you have edited and copied script as UTF-8 file and then strange chars come from UTF coding.

My advice: Copy scripts from Winbox to "stupid" NotePad and then look for nonstandard characters. Remove them and copy the script back .

Hmm, I think you're right, when I paste that character into an online UTF decoder it shows as "medium shade".
I'll see if I can make my program output ascii.

thanks

tslytsly

Re: strange problem importing rsc script

Posted: Wed Feb 17, 2016 4:36 pm
by tslytsly
That was it!
I never even considered the text encoding, it seems vb.net uses UTF-8 by default.
I just had to force it to write the script using ASCII.

Thanks BartoszP

tslytsly

Re: strange problem importing rsc script

Posted: Wed Feb 17, 2016 5:13 pm
by BartoszP
Notepad++ will/should be your friend :-)

Re: strange problem importing rsc script

Posted: Fri Feb 19, 2016 11:28 am
by tslytsly
Notepad++ will/should be your friend :-)
Actually I already use it for everything.
I even have a custom style for RouterOS so rsc files look like the terminal.. 8)

in this case Notepad++ didn't show the medium shade characters.

Re: strange problem importing rsc script

Posted: Fri Feb 19, 2016 2:11 pm
by BartoszP
As it silently have recognized as UTF so the script had been displayed/saved directly as UTF.
Sometimes notepad is the best tool ...