2013-11-22 237 views
-3

我有一個shell腳本,它將一些變量傳遞給名爲Deploy.pl的perl腳本。但似乎perl腳本沒有選擇變量。我一直在試圖找出原因,但無法解決它。除了$ entname變量外,其他變量正確傳遞給perl腳本。同樣的varibale我用我的複製語句,但因爲它沒有得到由Perl腳本拾取我得到一個無法找到路徑錯誤。請查看shell腳本和perl腳本。我知道放這麼長的腳本是瘋狂的,但我想清楚地知道腳本正在發生什麼。無法將變量從shell腳本傳遞到perl腳本

Shell腳本:

 #!/bin/bash 

sleep 1 
echo "##### Please Read the following information carefully ####" 
sleep 2 
echo "Please read this preamble in order to run the script. It states the adamant requirement that user needs to have while executing the script." 
echo " " 
echo "1. The script requires the user name(i.e. TIBID) which should have SVN access in order to execute it successfully. Example: ./deploy.sh tib7826" 
echo " " 
echo "where tib7826 is the user who has SVN access. Make sure the tibid you are using should have full SVN access." 
echo " " 
echo "2. The script further requires the Internal name as input. MDM creates a directory in the MQ_COMMON_DIR with internal name.It is" 
echo " " 
echo "case-sensitive and should be exact as what it is there in MQ_COMMON_DIR." 
echo " " 
echo "3. Further it asks for envoirnment name. The Environment name should be like DEV1,DEV2,DEV3,TEST1,TEST2 etc.Make sure they too are case specific." 
echo "Otherwise it will fail to execute further steps." 
echo " " 
echo " 4. The script requires CATALOG ID's as a input for the below 4 repositories" 
echo " " 
echo " a.ITEM_MASTER" 
echo " " 
echo " b.DISTRIBUTION_FACILITY_LV" 
echo " " 
echo " c.MANAGEMENT_DIVISION_SOI" 
echo " " 
echo " d.ALTERNATE IDENTIFICATIONS" 
echo " " 
echo "You will get those ID's from MDM Web UI. Login to the MDM UI. Go to Item Data==>Repositories==>ID Column." 
echo " " 
echo "5. For more detail read the Readme.txt in order to execute this script.Take it from the location" 
echo " " 
echo "/tibco/data/GRISSOM2/build_deploy_scripts_kroger/document" 
echo " " 
echo " Or else take the ReadMe form SVN." 
echo " " 
echo "If you agree to execute the script press Y else N." 
read uinput 
if [ $uinput == 'Y' ]; then 
echo "Script will execute!!" 
sleep 3 
else 
echo "You have Cancel the Agreement" 
exit 
fi 




# sample command to execute the deploy script ./deploy.sh tib7777 

# export the build root 
export BUILD_ROOT=/tibco/data/GRISSOM2 

# CUSTOM env variables are temporary and set directly in the script to execute custom tasks 
export CUSTOM1=/tibco/data/GRISSOM2/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/rulebase 

cd $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common 


echo "--- - - - - - - - - - - - - - - " 
echo "Enter your Enterprise INTERNAL NAME:" 
sleep 1 
read internal_name 

sleep 2 

echo "Enter Enterprise Name" 

read entname 

#code to check if the Enterprise with the correct INTERNAL name exists 

if [ -d "$MQ_COMMON_DIR/$internal_name" ]; then 
echo "Artifacts for the $internal_name will be deployed" 
else 
echo "THE ENTERPRISE with the $internal_name doesn't seems to be correct INTERNAL NAME. Execute the script again with the correct INTERNAL NAME" 
exit 
fi 


#This snippet will cleanup the existing MDR_ITME_E1 before we get the latest code for MDR_ITME_E1 enterprise from SVN 

cd $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common 
if [ -d "$entname" ]; then 
rm -rf $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common/$entname 
echo "Removing existing $entname from SVN source directory.." 
echo "..." 
sleep 1 
echo "...." 
sleep 1 
echo "....." 
sleep 1 
else 
echo "$entname Doesn't Exist for the first time" 
fi 

echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" 

echo "Retrieving Latest Code from SVN..." 
sleep 2 

echo "Please wait......" 
echo "Connecting to SVN." 
sleep 1 
echo "Connecting to SVN.." 
sleep 1 
echo "Connecting to SVN..." 
sleep 1 
echo "Connecting to SVN...." 
sleep 1 
echo "Connecting to SVN....." 
sleep 1 
echo "Connecting to SVN......" 
sleep 1 
echo "Connecting to SVN......." 
sleep 1 
echo "Connecting to SVN........" 

echo "Do you want to checkout the latest version of the COMMON DIR code [Y] or [N]" 
read svninput 

if [ $svninput == 'Y' ]; then 

echo "Downloading SVN Code" 

        if [ $entname == 'MDR_ITEM_E1' ]; then 

echo svn co --username $1 http://svn.kroger.com/repos/mercury/tibcomdm/cim_paris/branches/Grissom2_Development/common/MDR_ITEM_E1 
svn co --username $1 http://svn.kroger.com/repos/mercury/tibcomdm/cim_paris/branches/Grissom2_Development/common/MDR_ITEM_E1 
sleep 3 
        else 
echo "Copying E2 code" 

echo svn co --username $1 http://svn.kroger.com/repos/mercury/tibcomdm/cim_paris/branches/Grissom2_breakfix/common/MDR_ITEM_E2 
svn co --username $1 http://svn.kroger.com/repos/mercury/tibcomdm/cim_paris/branches/Grissom2_breakfix/common/MDR_ITEM_E2 

        fi 

else 
echo "Enter the revision number of the common directory" 
read revision 
        if [ $entname == 'MDR_ITEM_E1' ]; then 

svn co --username $1 -r $revision http://svn.kroger.com/repos/mercury/tibcomdm/cim_paris/branches/Grissom2_Development/common/MDR_ITEM_E1 
        else 
echo "E2 Code" 
svn co --username $1 -r $revision http://svn.kroger.com/repos/mercury/tibcomdm/cim_paris/branches/Grissom2_breakfix/common/MDR_ITEM_E2  
        fi 

echo "Loaded code for Enterprise" 

fi 



if [ -d $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common/$entname ] ; then 
echo "Downloaded latest code from SVN!!" 
else 
echo "CODE has not been downloaded. Please check your credentials." 
exit 
fi 


#echo svn co --username $1 http://svn.kroger.com/repos/mercury/tibcomdm/cim_paris/branches/Grissom2_Development/common/MDR_ITEM_E1 

#svn co --username $1 http://svn.kroger.com/repos/mercury/tibcomdm/cim_paris/branches/Grissom2_Development/common/MDR_ITEM_E1 

echo "========================================" 

echo "Taking destination organization backup...wait" 

cd $MQ_COMMON_DIR/$internal_name 
chmod -Rf 777 $MQ_COMMON_DIR/$internal_name 
sleep 2 
cp -rf /$MQ_COMMON_DIR/$internal_name /$MQ_COMMON_DIR/$internal_name$(date +%d%m%Y%H%M) 
echo "backup done!!" 
chmod -Rf 775 $MQ_COMMON_DIR/$internal_name * 
echo "========================================" 

#Removing contents inside the workflow,forms,maps,rules,rulebase,schema,templates,inputmap 
sleep 2 
echo "Removing contents inside workflow,inputmap,rules......" 
echo "." 
sleep 1 
echo ".." 
sleep 1 
echo "..." 
sleep 1 

if [ -d "$MQ_COMMON_DIR/$internal_name" ]; then 

# cleanup the enterprise internal directories 
rm -rf $MQ_COMMON_DIR/$internal_name/workflow/* 

rm -rf $MQ_COMMON_DIR/$internal_name/forms/* 

rm -rf $MQ_COMMON_DIR/$internal_name/rulebase/* 

rm -rf $MQ_COMMON_DIR/$internal_name/maps/* 

rm -rf $MQ_COMMON_DIR/$internal_name/templates/* 

else 
echo "THE ENTERPRISE with the $internal_name internal name does not exist. Execute the script with the correct INTERNAL NAME" 
exit 
fi 

sleep 2 
echo "The following folders[workflow, forms, rulebase, maps, templates] have been cleaned up in the Enterprise common directory" 

cd $MQ_COMMON_DIR/$internal_name 

echo "Inside internal enterprise" 
echo "-------------" 

echo "InputMap,Schema,Scheduler,Distributedlock...Creating!!" 
sleep 2 


if [ -d "inputmap" ] && [ -d "schema" ] && [ -d "scheduler" ] && [ -d "distributedlock" ]; then 
echo "Copying the directory structure" 
echo "inputmap, schema,scheduler,distributedlock exists!!" 

else 

mkdir inputmap 
mkdir schema 
mkdir scheduler 
mkdir distributedlock 
chmod 775 *.* 

sleep 1 
echo "Required additional directories have been created!" 
fi 

#Enter Environment Name:  

echo "Options: Which Enviroment you want to Deploy 1.DEV1 2.DEV2 3.DEV3 4.TEST1 5.TEST2 6.E2E 7.STAGE 8.PRODUCTION" 

echo "Enter Environment Name:" 
read env_name 
if [ $env_name == DEV1 -o $env_name == DEV2 -o $env_name == DEV3 -o $env_name == TEST1 -o $env_name == TEST2 -o $env_name == E2E -o $env_name == STAGE -o $env_name == PRODUCTION ] ; then 
echo "Running" 
else 
echo "You Entered wrong Environment Name!! Enter correct environment name and run the script again." 
exit 
fi 

#Input catalog ID's==specific to E1 enterprise code only 

if [ $entname == 'MDR_ITEM_E1' ]; then 

echo "Enter Catalog ID's to copy the CV and Catalogvalidation files" 

echo "Enter Catalog ID For ITEM_MASTER" 
read item 
     if [ -d "$MQ_COMMON_DIR/$internal_name/catalog/master/$item" ]; then 
echo "renaming existing catalogvalidation.xml as a backup copy" 
cd $MQ_COMMON_DIR/$internal_name/catalog/master/$item 
mv catalogvalidation.xml catalogvalidation.xml$(date +%d%m%Y%H%M) 
     else 
echo "Either directory or file does not exist" 
     fi 

echo "Enter Catalog ID For DISTRIBUTION_FACILITY_LV" 
read dflv 
     if [ -d "$MQ_COMMON_DIR/$internal_name/catalog/master/$dflv" ]; then 
echo "renaming existing catalogvalidation.xml as a backup copy" 
cd $MQ_COMMON_DIR/$internal_name/catalog/master/$dflv 
mv catalogvalidation.xml catalogvalidation.xml$(date +%d%m%Y%H%M) 
     else 
echo "Either directory or file does not exist" 
     fi 

echo "Enter Catalog ID For MANAGEMENT_DIVISION_SOI" 
read mds 
     if [ -d "$MQ_COMMON_DIR/$internal_name/catalog/master/$mds" ]; then 
echo "renaming existing catalogvalidation.xml as a backup copy" 
cd $MQ_COMMON_DIR/$internal_name/catalog/master/$mds 
mv catalogvalidation.xml catalogvalidation.xml$(date +%d%m%Y%H%M) 
     else 
echo "Either directory or file does not exist" 
     fi 


echo "Enter Catalog ID For ALTERNATE_IDENTIFICATION_MVL" 
read aim 
     if [ -d "$MQ_COMMON_DIR/$internal_name/catalog/master/$aim" ]; then 
echo "renaming existing catalogvalidation.xml as a backup copy" 
cd $MQ_COMMON_DIR/$internal_name/catalog/master/$aim 
mv catalogvalidation.xml catalogvalidation.xml$(date +%d%m%Y%H%M) 
     else 
echo "Either directory or file does not exist" 
     fi 

echo "Copying CV Files" 

cp -rf $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/catalog/master/34731_ITEM_MASTER/cv_* $MQ_COMMON_DIR/$internal_name/rulebase/ 
cp -rf $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/catalog/master/34800_DISTRIBUTION_FACILITY_LV/cv_* $MQ_COMMON_DIR/$internal_name/rulebase/ 
cp -rf $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/catalog/master/34800_DISTRIBUTION_FACILITY_LV/DISTRIBUTION_FACILITY_LV.xml $MQ_COMMON_DIR/$internal_name/rulebase/ 
cp -rf $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/catalog/master/34801_MANAGEMENT_DIVISION_SOI/cv_* $MQ_COMMON_DIR/$internal_name/rulebase/ 
#cp -rf $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/catalog/master/ALTERNATE_IDENTIFICATION_MVL/cv_* $MQ_COMMON_DIR/$internal_name/rulebase/ 
sleep 3 
echo "....." 
sleep 1 
echo "......." 
sleep 1 
echo "........." 
echo "Copied CV files" 

#Copying E2 Specific Code--Customized Files 
else 
#Copy E2 files 
sleep 3 

echo "Running the Deploy.pl..." 
sleep 4 

fi 
# run the deploy script 

cd $BUILD_ROOT/build_deploy_scripts_kroger/deploy_script 

./Deploy.pl $env_name $item $dflv $mds $aim MDR_ITEM_E2 $internal_name 


# custom code changes 
# custom1 to change the rulebase URLs 
echo " " 
echo " " 
echo "********************" 

echo "========================================" 

if [ $entname == 'MDR_ITEM_E1' ]; then 
echo "Copying schema for $internal_name internal enterprise name" 

if [ $env_name == DEV3 -o $env_name == TEST2 -o $env_name == DEV2 ]; then 
echo "Copying $env_name schema" 
cd /tibco/mdm/8.3/common/$internal_name/schema/ 

rm *.* 
cp /tibco/data/GRISSOM2/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/schema/TEST2/* /tibco/mdm/8.3/common/$internal_name/schema/ 

else 
     if [ $env_name == E2E ]; then 
     echo "Copying schema for $env_name environment!!" 
     cd /tibco/mdm/8.3/common/MDRITME1/schema/ 
     rm *.* 
     cp /tibco/data/GRISSOM2/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/schema/E2E/* /tibco/mdm/8.3/common/$internal_name/schema/ 
     else 
     echo "Incorrect environment name" 
     exit 
     fi 
fi 

echo "=========================================" 

else 
echo "E2 code is deploying..." 
fi 




if [ $entname == 'MDR_ITEM_E1' ]; then 

echo "Do you want to copy DropZone press Y to continue else N" 
read dr 
if [ "$dr" == 'Y' ]; then 
echo "Copying DropZone" 
cp -rf /tibco/data/GRISSOM2/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/DropZone/* $MQ_COMMON_DIR/$internal_name/DropZone/ 
echo "Copied DropZone" 
sleep 1 
else 
echo "either folder doesn't exist in $internal_name or You have cancelled the copy opeeation for DropZone" 
fi 


echo "Do you want to copy EAI press Y to continue else N" 
read eai 
if [ "$eai" == 'Y' ]; then 
echo "Copying EAI" 
cp -rf /tibco/data/GRISSOM2/DEPLOYMENT_ARTIFACTS/common/MDR_ITEM_E1/EAI/* $MQ_COMMON_DIR/$internal_name/EAI/ 
echo "Copyied EAI" 
sleep 1 
else 
echo "either folder doesn't exist in $internal_name or You have cancelled the copy opeeation for DropZone" 
fi 


else 
echo "#$%#$%#$%#$%#$%&*^&*#@$" 
fi 

cd $MQ_COMMON_DIR/$internal_name 

echo "****** The following directories have been deployed to your Enterprise Internal directory ********" 
echo "  " 

echo "======================================" 
ls | tee -a 
echo "=======================================" 

#change the permissions back to standard on the internal directory 

#chmod -Rf 775 $MQ_COMMON_DIR/$internal_name 
cd $MQ_COMMON_DIR/$internal_name 
chmod -Rf 644 * 

cd $MQ_COMMON_DIR/$internal_name 
find . -type d -exec chmod 0755 {} \; 

cd $MQ_COMMON_DIR/$internal_name 
chmod -Rf 777 EAI 
chmod -Rf 777 DropZone 
chmod -Rf 777 distributedlock 

echo "Permissions changed!" 
echo "========================================" 
echo " " 
echo " " 
echo " " 
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" 
echo "Deployed resources successfully" 
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" 
echo " " 
echo " " 
exit 

Perl腳本:

 #!/usr/bin/perl 


use CIMDeploymentVaribles; 

&main; 



sub main() 

{ 

     print "\n Deployment Script \n\n\n"; 

     #print "Options: Which Enviroment you want to Deploy\n 1.DEV1\n 2.DEV2\n 3.TEST1\n 4.TEST2\n 5.STAGE\n 6.PRODUCTION \n\n"; 

       $dep_env = $ARGV[0]; 
       $item_master = $ARGV[1]; 
       $distribution_facility_lv = $ARGV[2]; 
       $management_division_soi = $ARGV[3]; 
       $altername_identification_mvl = $ARGV[4]; 
       $entname = $ARGV[5]; 
       $internal_name = $ARGV[6]; 

        $SVN_COMMON_DIR_LOCATION = "/tibco/data/GRISSOM2/DEPLOYMENT_ARTIFACTS"; 
        $SCRIPT_LOCATION = "$SVN_COMMON_DIR_LOCATION/build_deploy_scripts_kroger/deploy_script"; 

        if ($dep_env eq 'DEV1' || $dep_env eq 'DEV2'|| $dep_env eq 'TEST1' || $dep_env eq 'TEST2' || $dep_env eq 'STAGE'|| $dep_env eq 'PRODUCTION' || $dep_env eq 'LOCALDEV1' || $dep_env eq 'MAHANADI'|| $dep_env eq 'DEV3' || $dep_env eq 'E2E') 
        { 

            print "\n Deployment on Environment:: $dep_env\n"; 

            &Set_Environment_Variables($dep_env); 
            &display_variables($dep_env); 
            &Deploy_Common_dir_artifacts($dep_env); 

        } 

        else 
        { 
          print "\nWrong argument is passed\n"; 
          print " \n Provide valid argument: DEV1 or DEV2 or TEST1 or TEST2 or STAGE or PRODUCTION\n\n"; 
          exit; 
        } 
} 


sub display_variables() 
{ 

     print "\n Displaying Variables Start\n"; 

     print "\n MQ_HOME on $_[0] :: $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}\n"; 
     print "\n MQ_COMMON_DIR on $_[0] :: $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}\n"; 
     print "\n ENTERPRISE_INTERNAL_NAME in $_[0] :: $ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}\n"; 
     print "\n SCRIPT_LOCATION in $SCRIPT_LOCATION\n"; 
     print "\n SVN_COMMON_DIR_LOCATION in $SVN_COMMON_DIR_LOCATION\n"; 

     print "\n Displaying Variables Ended \n"; 

} 
sub Set_Environment_Variables() 
{ 

     print "\n Setting up environment Variables\n"; 

     $ENV{"MQ_HOME"}="$ENV_Variables{\"$_[0]\"}{'MQ_HOME'}"; 

     $ENV{"MQ_COMMON_DIR"}="$ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}"; 

     print "\nEnvironment Variables are set\n"; 

} 


sub Deploy_Common_dir_artifacts() 
{ 

     print "\n Deploying common dir aftifacts for $_[0] environment \n"; 

     print "\nDeploying common dir artifacts to specific enterprise ($ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}) \n"; 

     print "Command: rm -rf `find $SVN_COMMON_DIR_LOCATION -type d -name .svn`"; 

     system("rm -rf `find $SVN_COMMON_DIR_LOCATION -type d -name .svn`"); 

     # Deploying forms 

     print "\n 1. Deploying forms \n"; 

     print "\nExecuting::: cp $SVN_COMMON_DIR_LOCATION/common/$entname/forms/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/forms/\n"; 

     system("cp $SVN_COMMON_DIR_LOCATION/common/$entname/forms/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/forms/"); 

     # Deploying maps 

     print "\n 2. Deploying maps \n"; 

     print "\nExecuting::: cp $SVN_COMMON_DIR_LOCATION/common/$entname/maps/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/maps/ \n"; 

     system("cp $SVN_COMMON_DIR_LOCATION/common/$entname/maps/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/maps/"); 

     # Deploying rulebase 

     print "\n 3. Deploying rulebase \n"; 

     print "\nExecuting::: cp -r $SVN_COMMON_DIR_LOCATION/common/$entname/rulebase/*  $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/rulebase/\n"; 

     system("cp -r $SVN_COMMON_DIR_LOCATION/common/$entname/rulebase/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/rulebase/"); 

     print "\n\n Executing ::: find $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/rulebase/* -type f -exec sed -i 's/$internal_name/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/' {} \\;"; 

     system("find $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/rulebase/* -type f -exec sed -i 's/$internal_name/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/' {} \\;"); 

     # Deploying workflow 

     print "\n 4. Deploying workflow \n"; 

     print "\nExecuting::: cp -r $SVN_COMMON_DIR_LOCATION/common/$entname/workflow/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/workflow/\n"; 

     system("cp -r $SVN_COMMON_DIR_LOCATION/common/$entname/workflow/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/workflow/"); 

     print "\n\n Executing ::: find $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/workflow/* -type f -exec sed -i 's/MDR_NEW/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/' {} \\;"; 

     system("find $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/workflow/* -type f -exec sed -i 's/$internal_name/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/' {} \\;"); 

     # Deploying htmlprops 

     print "\n 6. Deploying htmlprops \n"; 

     # print "\nExecuting::: cp $SVN_COMMON_DIR_LOCATION/common/$entname/htmlprops/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/htmlprops/\n"; 

     #system("cp -rf $SVN_COMMON_DIR_LOCATION/common/$entname/htmlprops/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/htmlprops/"); 

     # Deploying templates 

     print "\n 7. Deploying Templates \n"; 

     print "\nExecuting::: cp $SVN_COMMON_DIR_LOCATION/common/$entname/templates/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/templates/\n"; 

     system("cp $SVN_COMMON_DIR_LOCATION/common/$entname/templates/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/templates/"); 

     # Deploying Schedular 

     print "\n 8. Deploying scheduler \n"; 

     print "\nExecuting::: cp -r $SVN_COMMON_DIR_LOCATION/common/$entname/scheduler $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/\n"; 

     #system("cp -r $SVN_COMMON_DIR_LOCATION/common/$entname/scheduler/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/scheduler/"); 

     # Deploying Filewatcher 

     print "\n 9. Deploying Filewatcher \n"; 

     print "\nExecuting::: cp $SVN_COMMON_DIR_LOCATION/config/FileWatcher.xml $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/config/\n"; 

     system("cp $SVN_COMMON_DIR_LOCATION/config/FileWatcher.xml $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/config/"); 

     # Deploying Custom Properties 

     # print "\n 5. Deploying Custom Properties \n"; 

     # print "\nExecuting::: cp -r $SVN_COMMON_DIR_LOCATION/custom/* $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/custom/\n"; 

     # system("cp -r $SVN_COMMON_DIR_LOCATION/custom/* $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/custom/"); 

     # Deploying dynservices 

     print "\n 10. Deploying dynservices \n"; 

     print "\nExecuting::: cp -r $SVN_COMMON_DIR_LOCATION/dynservices $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/\n"; 

     #system("cp -r $SVN_COMMON_DIR_LOCATION/dynservices $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/"); 


     # Deploying InputMap 

     print "\n 12. Deploying InputMap \n"; 

     print "\nExecuting::: cp -r $SVN_COMMON_DIR_LOCATION/inputmap/* $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/inputmap/\n"; 

     #system("cp -r $SVN_COMMON_DIR_LOCATION/schema/* $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/schema/"); 
     system("cp -r $SVN_COMMON_DIR_LOCATION/common/$entname/inputmap/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/inputmap/"); 

     # Deploying DistributeLock 

     print "\n 13. Deploying DistributedLock \n"; 

     print "\nExecuting::: cp -r $SVN_COMMON_DIR_LOCATION/distributedlock/* $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/distributedlock/\n"; 

     #system("cp -r $SVN_COMMON_DIR_LOCATION/schema/* $ENV_Variables{\"$_[0]\"}{'MQ_HOME'}/schema/"); 
     system("cp -r $SVN_COMMON_DIR_LOCATION/common/$entname/distributedlock/* $ENV_Variables{\"$_[0]\"}{'MQ_COMMON_DIR'}/$ENV_Variables{\"$_[0]\"}{'ENTERPRISE_INTERNAL_NAME'}/distributedlock/"); 

} 

失敗:打印「\ nExecuting ::: CP $ SVN_COMMON_DIR_LOCATION /普通/ $ entname /表格/ * $ {ENV_Variables \ 「$ _ [0] \」} { 'MQ_COMMON_DIR'}/$ ENV_Variables {\ 「$ _ [0] \」} { 'ENTERPRISE_INTERNAL_NAME'} /形式/ \ n「個;

由於$ entname沒有拿起它不復制預期的文件。

+7

你說得對:發表這麼長的腳本是瘋狂的。其中大部分是無關緊要的。舉個簡單的例子。 –

+1

我同意。發佈如此大而且不相關的代碼示例並不是一個好主意,因爲它看起來像你的努力是微不足道的。直指問題,如果有人想要更多的背景,讓他們問。 – TLP

+0

當你也得到'$ SVN_COMMON_DIR_LOCATION'時,我看不出如何從輸出中看出「$ entname沒有被拾取」 - 看起來沒有變量正在被擴展。 –

回答

3

你真的需要開始propertly引用您的腳本:

rm -rf $BUILD_ROOT/DEPLOYMENT_ARTIFACTS/common/$entname 

想象我進入MDR_ITEM_E1 /。該命令現在將刪除磁盤上的所有文件。