The following shell script is working fine while I execute it from a Linux prompt, but when it's called by a Unix service (e.g. inetd, etc.) it doesn't recognize the $ACT_NUM variable inside the Perl script.
export ACT_NUM=$1
perl -pi -e '$v=$ENV{ACT_NUM};s/TRIGGER_VALUE" value="\d*"/TRIGGER_VALUE" value="$v"/>//' soa_triggering.xml
The soa_triggering.xml content file is
<ins:Parameter name="TRIGGER_VALUE" value="1"/>
I think your problem is more fundamental than expansion of
$1- I'm going to hazard a guess that the regex isn't matching - because:Is actually broken syntax - you're using
/as your regex separator, but you're also trying to include it in your pattern.So if you actually run this code you get:
So perhaps you need to consider escaping some of your meta characters:
This works:
But really - messing around with
XMLusing regular expressions is an inherently bad idea.You also might want to double check that that environment actually is being propagated. If you
print $v(or$ENV{ACT_NAME}) does it actually work?So how about instead: