Community discussions

MikroTik App
 
User avatar
tslytsly
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 65
Joined: Tue Oct 27, 2015 6:52 pm
Location: Nottingham
Contact:

strange problem importing rsc script

Wed Feb 17, 2016 3:10 pm

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
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3045
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: strange problem importing rsc script

Wed Feb 17, 2016 3:16 pm

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 .
 
User avatar
tslytsly
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 65
Joined: Tue Oct 27, 2015 6:52 pm
Location: Nottingham
Contact:

Re: strange problem importing rsc script

Wed Feb 17, 2016 4:11 pm

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
 
User avatar
tslytsly
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 65
Joined: Tue Oct 27, 2015 6:52 pm
Location: Nottingham
Contact:

Re: strange problem importing rsc script

Wed Feb 17, 2016 4:36 pm

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
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3045
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: strange problem importing rsc script

Wed Feb 17, 2016 5:13 pm

Notepad++ will/should be your friend :-)
 
User avatar
tslytsly
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 65
Joined: Tue Oct 27, 2015 6:52 pm
Location: Nottingham
Contact:

Re: strange problem importing rsc script

Fri Feb 19, 2016 11:28 am

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.
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3045
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: strange problem importing rsc script

Fri Feb 19, 2016 2:11 pm

As it silently have recognized as UTF so the script had been displayed/saved directly as UTF.
Sometimes notepad is the best tool ...