Invoking shell script with perl command.

Hi All,
I am using the following command to invoke the shell script from a perl command.

perl -i.bak -pe'BEGIN { $cmd = "/opt/coreservices/tomcat-5.5.9/bin/digest.sh -a sha"; }
s/(password=")([^"]*)/
$1.`$cmd $2|cut -d: -f2|tr -d "\n"`
/e
' $CATALINA_HOME/conf/tomcat-users.xml

I need to put in $CATALINA_HOME where I have /opt/coreservices/tomcat-5.5.9 , so the statement should be something like

perl -i.bak -pe'BEGIN { $cmd = "$CATALINA_HOME/bin/digest.sh -a sha"; }
s/(password=")([^"]*)/
$1.`$cmd $2|cut -d: -f2|tr -d "\n"`
/e
' $CATALINA_HOME/conf/tomcat-users.xml

Now since perl does not understand the shell variables, I did the following, but it is not working.

typeset -x MY_VARIABLE=$CATALINA_HOME
perl -i.bak -pe'BEGIN { $cmd = "$MY_VARIABLE"/bin/digest.sh -a; }
s/(password=")([^"]*)/
$1.`$cmd $2|cut -d: -f2|tr -d "\n"`
/e
' $CATALINA_HOME/conf/tomcat-users.xml

Can anyone please help!

Hi !

You can get environment variable by through %ENV hash. In your case:

perl -i.bak -pe'BEGIN { $cmd = $ENV{CATALINA_HOME}/bin/digest.sh -a; }
s/(password=")([^"]*)/
$1.`$cmd $2|cut -d: -f2|tr -d "\n"`
/e
' $CATALINA_HOME/conf/tomcat-users.xml