I’m trying to run the following script from Terminal and get the “user” name of the l2tp-out1 interface and add that “user” name to a bootup script,
When I run this command on terminal separatly it outputs the l2tp-out user name successfully:
put [/interface l2tp-client get [find name=l2tp-out1] user]
but it’s not working inside the following script instead it just adds the above command it self inside the bootup script:
/system script add name=TestBoot source={
delay 15
/interface l2tp-client set numbers=l2tp-out1 user=(put [/interface l2tp-client get [find name=l2tp-out1] user]) password=xxccxx connect-to=192.168.1.5 disabled=no add-default-route=yes
}
Can someone suggest a solution please?
eworm
February 21, 2020, 3:31pm
2
You have to use square brackets ([ and ] ), not parenthesis (( and ) ).
And the “put” is wrong, it’s supposed to output to terminal. Just remove that (and the parenthesis).
Thank you for the reply @eworm , I tried both below by removing “()” and “put”, but still not working:
/system script add name=TestBoot source={
delay 15
/interface l2tp-client set numbers=l2tp-out1 user=[/interface l2tp-client get [find name=l2tp-out1] user] password=xxccxx connect-to=192.168.1.5 disabled=no add-default-route=yes
}
/system script add name=TestBoot source={
delay 15
/interface l2tp-client set numbers=l2tp-out1 user=[[/interface l2tp-client get [find name=l2tp-out1] user]] password=xxccxx connect-to=192.168.1.5 disabled=no add-default-route=yes
}