Community discussions

 
dominicbatty
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Wed Jul 07, 2010 12:26 pm

Replace and Command with a Variable

Fri Mar 09, 2012 2:36 pm

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.
 
airock
newbie
Posts: 29
Joined: Fri Oct 09, 2009 11:57 pm

Re: Replace and Command with a Variable

Sun Mar 11, 2012 10:27 am

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
"Entia non sunt multiplicanda praeter necessitatem."

If you find anything useful in this this post, please give a positive Karma. (more info about Karma)
 
dominicbatty
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Wed Jul 07, 2010 12:26 pm

Re: Replace and Command with a Variable

Sun Mar 11, 2012 1:00 pm

that's a great help rock, thanks for your reply. Dominic.

Who is online

Users browsing this forum: No registered users and 17 guests