Page 1 of 1

Replace and Command with a Variable

Posted: Fri Mar 09, 2012 2:36 pm
by dominicbatty
Hi,

I was wondering if anyone could answer me the following.

Take a command that populates a local variable "link1interfacestatus" with the current status of a pppoe-client interface with a name of "bob".

:set link1interfacestatus [/interface pppoe-client get [/interface pppoe-client find name="bob"] running];

is there anyway to pass into this call a variable instead of having to hard code the term "pppoe-client"?

i.e.

:local <variable> "pppoe-client";
:set link1interfacestatus [/interface <variable> get [/interface <variable>find name="bob"] running];

Nothing I do seems to be able to do this?

Thanks, Dominic.

Re: Replace and Command with a Variable

Posted: Sun Mar 11, 2012 10:27 am
by airock
Just a tip to show you the way:
:local item "pppoe-client"
:local command [:parse "/interface $item print"]
$command
The rest is left as an exercise for the reader. :D

Regards,
rock

Re: Replace and Command with a Variable

Posted: Sun Mar 11, 2012 1:00 pm
by dominicbatty
that's a great help rock, thanks for your reply. Dominic.