Community discussions

 
upnort
newbie
Topic Author
Posts: 45
Joined: Wed Aug 15, 2018 2:03 am

Scripting confusion

Wed Aug 21, 2019 2:57 am

If the following questions are answered in the wiki please show me where.

1. When I upload a script using scp or winbox, the script is always tagged as invalid. The file is tagged invalid because the contents are empty, as seen by the /system script print command. The file's source parameter is empty. How do I correctly upload a script from my computer?

2. The RouterOS system seems to automatically tag any uploaded *.rsc file as a script and places the script in the local /system script "repository." True or false?

3. Every time I run /system script print a script job is created. Why and how do I stop that?

4. Every time I am logged into a device with SSH and I remove a script job, either from the command line or winbox, my SSH session is terminated. Why and how do I stop that?

5. The only way I found to download a script from a device is /system script export file=script.rsc. This places a copy of the script in /file, but the file is not an exact duplicate of the original script. How do I download a script to my computer?

Using /system script edit test.rsc source, I manually created a script. I exported using /system script export file=test.rsc. Using winbox I deleted the files. I then uploaded the same file. The script was tagged invalid.

I tried different encodings and different line endings. The files are always tagged as invalid. When I create the script inside the device using /system script edit script.rsc source and manually add content, the script is accepted as valid.

I am working from a Linux system.

Thank you! :)
 
upnort
newbie
Topic Author
Posts: 45
Joined: Wed Aug 15, 2018 2:03 am

Re: Scripting confusion

Thu Aug 22, 2019 12:45 am

After much experimenting, looks like any *.rsc file uploaded to a device gets copied/duplicated as a script to /system script and is always empty. I tried various ways to upload a script, including various ways of emulating the carriage returns and newlines, but the file always ends up empty.

Is there no way to upload a script? Is the only option opening the RouterOS text editor and pasting?

Thanks. :)

Edit: I think I found a way. Thank you eworm!
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 148
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Scripting confusion

Thu Aug 22, 2019 12:57 pm

AD 1.1) You can upload via many ways a file to ROS file storage like ftp/winbox etc. ROS not delete a "source" of file. You should do just copy file from one PC to ROS.
AD 1.2) /System script and /File are two places. /File is storage of file. /System script is internal place and to create a script you must from CLI use /system script add ... .
One way is to use ftp and upload file "anynamewhohavethis.auto.rsc" will be running automatic and if this *.auto.rsc via ftp will have inside like like /system script add ... then this create your script.
AD 1.3) When you are logging via WinBox this is one JOB-session. Opening a Terminal in side WinBox open next one JOB. Running /system script run SomeScriptWithDelay30... show you next one JOB. This is like TaskManager in OS.
AD 1.4) Show AD 1.3 = you kill yourself session via ssh
AD 1.5) Yes, export do a COPY of SCRIPT. Check his content and you discover /system script add ... command.
To import it you use: /import file-name=your-export-to-import.rsc
AD 2post.null) Because you copy it to /file file-storage but you not do /import script.rsc to run it.

and
/import can work witch file bigger then 4K. This is best way. Just do /export file=example.rsc and do import it and you discover a mechanism.

Please mark [SOLVED] topic if you have all answers
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda

Who is online

Users browsing this forum: No registered users and 7 guests