The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
returning to the parent shell after invoking a script within a script gurukottur Shell Programming and Scripting 5 09-26-2006 04:05 AM
Invoking Shell Script via php bubeshj Shell Programming and Scripting 2 06-30-2006 03:09 AM
Invoking shell script from html/jsp page bubeshj Shell Programming and Scripting 2 06-28-2006 10:53 AM
invoking one shell script from other ajay xavier Shell Programming and Scripting 3 05-24-2006 12:39 AM
Wrong Shell Invoking My Script On Linux kowrip Shell Programming and Scripting 3 09-10-2003 07:18 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-10-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
Invoking shell script with perl command.

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

Code:
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

Code:
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.

Code:
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!
Reply With Quote
Forum Sponsor
  #2  
Old 07-10-2008
lunc
Guest
 

Posts: n/a
Hi !

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


Code:
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0