Re: Скрипт отправки внешнего IP на почту (если он изменился).
Добавлено: 02 июл 2018, 15:30
Смотрите у себя, 7-sky - это name или comment. Должно быть name. Потом, у вас какой тип подключения?
Форум поддержи и обмена опытом пользователей оборудования RouterBOARD и операционной системы RouterOS Латвийского производителя MikroTik
https://forummikrotik.ru/
Код: Выделить всё
[iron@MikroTik] > :local WAN "7-sky";
[iron@MikroTik] > :local smtpserv [:resolve "smtp.gmail.com"];
[iron@MikroTik] > :local Eaccount "fooname@gmail.com";
[iron@MikroTik] > :local Epassword "foopass";
[iron@MikroTik] > :local Etomail "secondfooname@gmail.com";
[iron@MikroTik] >
[iron@MikroTik] > :global StoredIP
[iron@MikroTik] > :global StoredIP
[iron@MikroTik] > :local sysname [/system identity get name];
[iron@MikroTik] > :local sysver [/system package get system version];
[iron@MikroTik] > :local CurrIP
[iron@MikroTik] > :log info "Get WAN interface IP address (New IP to e-mail script)"
[iron@MikroTik] >
[iron@MikroTik] > :set CurrIP [/ip address get [/ip address find interface=$WAN] address]
syntax error (line 1 column 6)
Код: Выделить всё
[podarok66@MikroTik] > :local r 34
[podarok66@MikroTik] > :put $r
[podarok66@MikroTik] >
Код: Выделить всё
[iron@MikroTik] > :local r 34
[iron@MikroTik] > :put $r
[iron@MikroTik] >
[iron@MikroTik] > put 34
34
[iron@MikroTik] >
Код: Выделить всё
:global currentIP [:resolve myip.opendns.com server=208.67.222.222]
[iron@MikroTik] > put $currentIP
x.x.x.x
[iron@MikroTik] >
Код: Выделить всё
:local someIP [:resolve myip.opendns.com server=208.67.222.222]
[iron@MikroTik] > put $someIP
[iron@MikroTik] >
Код: Выделить всё
[iron@MikroTik] > :set r 34
syntax error (line 1 column 6)
[iron@MikroTik] > set $r 34
[iron@MikroTik] > put $r
[iron@MikroTik] >
Код: Выделить всё
[podarok66@MikroTik] > :local r 34
[podarok66@MikroTik] > :put $r
[podarok66@MikroTik] >
Код: Выделить всё
[podarok66@RB750Gr3] > {:local r 34;
{... :put $r;
{... }
34
[podarok66@RB750Gr3] >
Последняя строка цитаты поясняет ситуацию из вашего первого поста. Вся цитата в целом описывает области применения переменных. Не пожалейте времени, почитайте. Многое станет ясно и будет казаться проще...Scopes
Variables can be used only in certain regions of the script. These regions are called scopes. Scope determines visibility of the variable. There are two types of scopes - global and local. A variable declared within a block is accessible only within that block and blocks enclosed by it, and only after the point of declaration.
Global scope
Global scope or root scope is default scope of the script. It is created automatically and can not be turned off.
Local scope
User can define its own groups to block access to certain variables, these scopes are called local scopes. Each local scope is enclosed in curly braces ("{ }").
.................
.................
Note: Each line written in terminal is treated as local scope