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 Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 08:05 AM
Invoking Shell Script via php bubeshj Shell Programming and Scripting 2 06-30-2006 07:09 AM
Invoking shell script from html/jsp page bubeshj Shell Programming and Scripting 2 06-28-2006 02:53 PM
invoking one shell script from other ajay xavier Shell Programming and Scripting 3 05-24-2006 04:39 AM
Wrong Shell Invoking My Script On Linux kowrip Shell Programming and Scripting 3 09-10-2003 11:18 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-10-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
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!
  #2 (permalink)  
Old 07-10-2008
lunc
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0