Community discussions

MikroTik App
 
eddieada
just joined
Topic Author
Posts: 17
Joined: Sat May 30, 2009 8:43 am

flags

Sat May 30, 2009 8:56 am

[admin@MikroTik] /interface ethernet> monitor ether3
status: link-ok
auto-negotiation: done
rate: 100Mbps
full-duplex: yes

[admin@MikroTik] /interface ethernet> monitor ether3
status: no-link
auto-negotiation: done
rate: 100Mbps
full-duplex: yes
an example of how to detect the "status:" in a script would be appreciated

See ya at the Dallas MUM if your there!
thanks
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: flags

Mon Jun 01, 2009 4:37 pm

:local myStatus "";
/inerface ethernet monitor ether2  once do={ :set myStatus $status }
:put "last status was $myStatus";
 
eddieada
just joined
Topic Author
Posts: 17
Joined: Sat May 30, 2009 8:43 am

Re: flags

Tue Jun 02, 2009 1:03 am

just what i needed to get started

thank you very much!
 
eddieada
just joined
Topic Author
Posts: 17
Joined: Sat May 30, 2009 8:43 am

Re: flags

Tue Jun 02, 2009 12:32 pm

I am new to scripting so please be patient with me.
after a few hours or so this is as close as I got to making this work fixing the typo in the word "internet" and changing the curly brackets to just plain parentheses

[jeff@MikroTik] > :local myStatus "";
[jeff@MikroTik] > /interface ethernet monitor ether2 once do=( :set myStatus $status ) ;
status: no-link
auto-negotiation: done
rate: 10Mbps
full-duplex: no
[jeff@MikroTik] > :put "last status was $myStatus";
expected end of command (line 1 column 23)
[jeff@MikroTik] >


i also tried this as the last line

[jeff@MikroTik] > :put "last status was $(myStatus)";
last status was
[jeff@MikroTik] >

i was exspecting it to return last status was no-link

im using ros3.20 if that makes a difference.
thanks
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: flags

Tue Jun 02, 2009 12:41 pm

in console each lien is treated like separate script, but local variables are available only within the current scope.
If you paste this script directly into console you have two options:
*) replace :local with :global or
*) put all script inside braces {}
 
eddieada
just joined
Topic Author
Posts: 17
Joined: Sat May 30, 2009 8:43 am

Re: flags

Tue Jun 02, 2009 12:48 pm

thank you for the quick reply and the excellent explanation

Who is online

Users browsing this forum: gargiuseppe and 6 guests