Community discussions

 
DanielDamito
just joined
Topic Author
Posts: 5
Joined: Mon Sep 11, 2017 9:42 pm

Global variable not working between two scripts

Tue Nov 14, 2017 7:30 pm

Hello, guys.

Im trying to develop two scripts:

script1:
  • Declare a global variable;
    Set its value;
    call script2;
script2:
  • Set a route filter's action to discard, finding this filter using the value of the global variable;
The script1 correctly calls the script2, but the script2 does not change the filter's action.
Please, could someone help me?

Below the exported scripts and the screenshot attached!
________________________________________________________________________________________________

/system script
add name=script1 owner=damito policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\
":global xpto\r\
\n:set xpto \"whatever\" \r\
\n/system script run script2"
add name=script2 owner=damito policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\
"/routing filter set action=discard [/routing filter find where chain=\$xpto];"
You do not have the required permissions to view the files attached to this post.
 
2frogs
Member
Member
Posts: 422
Joined: Fri Dec 03, 2010 1:38 am

Re: Global variable not working between two scripts

Tue Nov 14, 2017 7:42 pm

You need to declare the global variable in the second script as well.
 
DanielDamito
just joined
Topic Author
Posts: 5
Joined: Mon Sep 11, 2017 9:42 pm

Re: Global variable not working between two scripts

Tue Nov 14, 2017 8:39 pm

It worked, thank you ;)

Who is online

Users browsing this forum: No registered users and 11 guests