Community discussions

MikroTik App
 
petterg
Member Candidate
Member Candidate
Topic Author
Posts: 230
Joined: Wed Sep 16, 2009 2:55 pm

Variables named with a "-"

Wed Mar 27, 2019 1:30 am

I'm a noob when it comes to scripting mikrotik. How do you use varables with a name that contains a "-" ?

Reading the manual at https://wiki.mikrotik.com/wiki/Manual:PPP_AAA
For /ppp profile under section "on-up" it states:
Execute script on user login-event. These are available variables that are accessible for the event script:

user
local-address
remote-address
caller-id
called-id
interface
When I insert a script like this:
/log info message="test $user"
The log states "test myusername" every time myusername logs in.
But if I do the following:
/log info message="test $caller-id"
I don't get the caller id in the log. What I find in the log is "test -id"
How do I make use of this variable?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3334
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Variables named with a "-"  [SOLVED]

Wed Mar 27, 2019 8:26 am

You need to use double quotes for variable with spesial characters.
Then use parentheses and . to join text and variable.
Example:
[
:local "us-er" "demo"
:log info message= ("user=".$"us-er")
]

result in log file:
user=demo
You find information about double quote variable in the manual
https://wiki.mikrotik.com/wiki/Manual:Scripting
Search for "Valid characters"
 
petterg
Member Candidate
Member Candidate
Topic Author
Posts: 230
Joined: Wed Sep 16, 2009 2:55 pm

Re: Variables named with a "-"

Wed Mar 27, 2019 11:49 am

Thanks

Who is online

Users browsing this forum: korniza and 19 guests