Discussion:
[Shorewall-users] access shell variables in params from SHELL
Vieri Di Paola
2016-10-10 15:48:07 UTC
Permalink
Hi,
Is there a way to pass variables defined in "params" to the child processes spawned by SHELL or BEGIN SHELL?
I'd like to read a variable set in "params" within "SHELL".
Thanks,
Vieri
Tom Eastep
2016-10-10 16:20:40 UTC
Permalink
Post by Vieri Di Paola
Hi,
Is there a way to pass variables defined in "params" to the child
processes spawned by SHELL or BEGIN SHELL?
I'd like to read a variable set in "params" within "SHELL".
Yes -- just export those variables in your 'init' extension script.

- -Tom
- --
Tom Eastep \ When I die, I want to go like my Grandfather who
Shoreline, \ died peacefully in his sleep. Not screaming like
Washington, USA \ all of the passengers in his car
http://shorewall.net \________________________________________________
Vieri Di Paola
2016-10-10 18:09:37 UTC
Permalink
----- Original Message -----
Post by Tom Eastep
Post by Vieri Di Paola
Hi,
Is there a way to pass variables defined in "params" to the child
processes spawned by SHELL or BEGIN SHELL?
I'd like to read a variable set in "params" within "SHELL".>
Yes -- just export those variables in your 'init' extension script.
I'm not sure I understand.

# cat /etc/shorewall/init
export TEST_VAR=10.215.144.48

If I add the following to 'routes' then the condition is not met (variable is empty or undefined):

?BEGIN SHELL
if [ ${#TEST_VAR} -gt 0 ]; then
echo "main \$TEST_VAR - \$IF2"
fi
?END SHELL
Tom Eastep
2016-10-10 18:32:12 UTC
Permalink
Post by Vieri Di Paola
----- Original Message -----
Post by Tom Eastep
Post by Vieri Di Paola
Hi,
Is there a way to pass variables defined in "params" to the
child processes spawned by SHELL or BEGIN SHELL?
I'd like to read a variable set in "params" within "SHELL".>
Yes -- just export those variables in your 'init' extension
script.
I'm not sure I understand.
# cat /etc/shorewall/init export TEST_VAR=10.215.144.48
If I add the following to 'routes' then the condition is not met
?BEGIN SHELL if [ ${#TEST_VAR} -gt 0 ]; then echo "main
\$TEST_VAR - \$IF2" fi
My bad -- you need to export in the params file itself. Then this also
works:

?shell echo "${var}"

- -Tom
- --
Tom Eastep \ When I die, I want to go like my Grandfather who
Shoreline, \ died peacefully in his sleep. Not screaming like
Washington, USA \ all of the passengers in his car
http://shorewall.net \________________________________________________
Loading...