Scripting problems / email / upgrade routerboard

After upgrade ROS my “auto back and sent email” script not working .
my script is:
/system backup save name=email dont-encrypt=yes;
/tool e-mail send to=“test@outlook.com” subject=([/system identity get name]." (Backup Mikrotik RB951Ui-2HnD Configuration File)") file=email.backup;

Log show:
executing script script1 from winbox failed, please check it manually
syntax error (line 2 column 137)

Pl check my script it is working in previous version but not work 7.18 version

@nishadul

I can cut and paste those commands into a cli and they work. Does it work if you do the same and cut and paste from this comment?

Character 137 is the = after file. I wonder if there’s an issue with different quote characters or something.

The output from

/system/script export

In a code block would probably help


add dont-require-permissions=no name=script1 owner=nishadul policy=
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=“/system backup save name=email d
ont-encrypt=yes;\r
\n/tool e-mail send to="test@outlook.com" subject=([/system identity get name]." (Backup Mikrotik RB95
1Ui-2HnD Configuration File)") file=email.backup;”

It’s very hard to tell because you didn’t use a code block, but i think you may have an extra invisible character in there.

Try

/system script print where name=script1

And see if any characters are highlighted in red


[nishadul@Sherpur] > /system script print where name=script1
Flags: I - invalid
0 name=“script1” owner=“nishadul” policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon
dont-require-permissions=no last-started=2025-02-27 10:16:22 run-count=16
source=
/system backup save name=email dont-encrypt=yes;
/tool e-mail send to=“test@outlook.com” subject=([/system identity get name]." (Backup Mikrotik RB951U>
– [Q quit|D dump|right]

I have write full code in winbox system/script but winbox terminal show few code, not full code

Please note same script worked with ROS 6.49.13, there are no error I think this problem is mikrotik with winbox
mikrotik.png

My problem is solved after write file name in double quotes, Thank you of all

Like previously stated you can’t really try to compare string versions of floats. The scripting language has no notion of floats either.
The best solution I’ve found is to convert the floats to real numbers then compare those two numbers.
So if the current version is 7.15.2 and the upgrade version is 7.18 then the two values of $currver and $upver will be 22 and 25 respectively, then you can test for greater or less than or whatever you need.

    :local firmware [:system/routerboard/get current-firmware]
    :local upgrade [:system/routerboard/get upgrade-firmware]
    # convert X.xx.y to sum of X+xx for comparison (no floats)
    :set $curver ([pick $firmware 0 1] + [:pick $firmware 2 4])
    :set $upver ([pick $upgrade 0 1] + [:pick $upgrade 2 4])
	:if ($curver < $upver) do={
		# Do something important here
	}

If you need the the full float for comparison then you’ll need to add the .y portion too with another [:pick] command

Script Error: cannot add string to string
And is full of other errors.
Before you write this b–t, do you try them?

As I already wrote, it's useless, just let RouterOS do it, since you have to restart it anyway to use the new "bios"...

If you change ROS & firmware then it is enough to check if upgrade and current version differ as upgrade version is the one that goes in par with ROS despite you could actually upgrade or downgrade.

:if ($Var1**!=**$Var2)

BTW there is no way to easy compare testing versions as numbers as verions contains “betaN” or “rcN”.

I think he was looking for a script to pull in a new ROS version on a timer, not just upgrade the boot loader

That script works just fine. since I'm already using it. Maybe try it for yourself ?

It does not matter. If there is a newer version available, what means “with different version string”, then upgrade string != current one no matter if it is “bigger” or “lower” whatever bigger/lower could mean..

Do you really want to teach me the basics?
(for example :set $curver, where is already defined curver? why is present $ in face of curver, you try to add two strings, etc.)
Using your logic:

{
    :local firmware "7.17.1"
    :local upgrade  "7.17.2"
    :local curver ([pick $firmware 0 1] + [:pick $firmware 2 4])
    :local upver  ([pick $upgrade  0 1] + [:pick $upgrade  2 4])
    :put $curver
    :put $upver
    :if ($curver < $upver) do={ :put "the $upgrade is newer than $firmware" }
    :if ($curver > $upver) do={ :put "the $upgrade is older than $firmware" }
    :if ($curver = $upver) do={ :put "the $upgrade is same  than $firmware" }
}

the result is:

24
24
the 7.17.2 is same  than 7.17.1

Yes I know the basics, however the snippet I provided was not the full context just the important piece.

Also you failed the read the part where I stated if you want the full value that another pick statement is required.

So important it’s wrong. For “him” 7.17.1 and 7.17.2 are the same thing… Ignoring then that 7.9.x and lower give an error…

don’t try to climb up the mirrors…


{
    :local firmware "7.17.2"
    :local upgrade  "7.18"
    :local curver ([pick $firmware 0 1] + [:pick $firmware 2 4] + [:pick $firmware 5 7])
    :local upver  ([pick $upgrade  0 1] + [:pick $upgrade  2 4] + [:pick $upgrade  5 7])
    :put $curver
    :put $upver
    :if ($curver < $upver) do={ :put "the $upgrade is newer than $firmware" }
    :if ($curver > $upver) do={ :put "the $upgrade is older than $firmware" }
    :if ($curver = $upver) do={ :put "the $upgrade is same  than $firmware" }
}



26
25
the 7.18 is older than 7.17.2

(aside from the fact that it is more correct to divide at each point, rather than dividing only based on position)

at most it should be compared as
7 * 10000 + 17 * 100 + 2 = 71702
7 * 10000 + 18 * 100 + 0 = 71800
so 71800 > 71702
without taking into account ab_xx_, alpha_x_, beta_x_, rc_x_, etc.

It’s seems you’re a fountain of elitist knowledge. I’ll just refrain from trying to assist anyone in the future since you’re so adept at it.
All I was trying to do is offer a possible solution to the floats issue. I may not be perfect but my requirements only care about the first two values not the sub version.

Instead of being sarcastic, try to understand what I wrote, that these are free lessons.
It doesn’t matter if you admit that you take them into consideration, no one will ever know.

No one is elite or infallible, insistence is wrong, especially when there is a clear and simple solution:

/system routerboard settings set auto-upgrade=yes

already written clearly, without further hijacking this thread.

Now I hope the moderators (kindly) remove all this crap from the topic (and I’m not just referring to these last posts)

Moved.