Hi,
I am writing a script in which I am using AWK to append to a line in a file and save the file. The command I am using is:
Code:
awk '{s=$0; if ( NR==4 ){s=s ":/usr/java/jdk1.6.0_19/bin" } print s;}' $appName > $appName.new
This works perfectly on the command line. However when I insert the same command in my shell script, the script ignores everything after the first $appName.
The $appName variable is an input to the script.
Similar thing happens when I use SED to replace a piece of text in another file in the same script.
Code:
sed 's/DEV/UAT/g' Properties>Properties.tmp
Again, this works perfectly on command line.
My shell is BASH & I am using Redhat Enterprise Linux.
My entire script is:
Code:
export APPPATH=~/Library/WebObjects/Applications
export APPNAME=$1
# Prepare the deployment env.
prep_env()
{
typeset appName=$1
cd ~/Builds
if [[ -e $appName* ]]; then rm $appName*
fi
curl -O http://smithers.apple.com/hudson/job/RJV-trunk-RJVApps-DEV/com.apple.rjv.app'$'$appName/lastSuccessfulBuild/artifact/com.apple.rjv.app/$appName/1.0.0.0-SNAPSHOT/$appName-1.0.0.0-SNAPSHOT-wod
ocroot.tar.gz
tar -C ~/Backups/ -xf $appName*
}
append_path()
{
# Modify the path declaration line in the Application launch file.
typeset appName=$1
typeset appPath=$APPPATH
cd $appPath/$appName.woa
exec awk '{s=$0; if ( NR==4 ){s=s ":/usr/java/jdk1.6.0_19/bin" } print s;}' $appName > $appName.new
# | mv $appName.tmp $appName | chmod +x $appName
}
modify_prop()
{
#Modify the Environment Setting in the Properties file from DEV to UAT
typeset appName=$1
typeset appPath=$APPPATH/$appName.woa/Contents/Resources
cd $appPath
exec sed 's/DEV/UAT/g' Properties>Properties.tmp && mv Properties.tmp Properties
}
prep_env $APPNAME
append_path $APPNAME
modify_prop $APPNAME