Bash script execution error
Hello everybody,
My situation is a little difficult but i will try to explain what is the exact problem that i am facing.I have a bash script that I want to execute.
The script is described below and I am executing it on a Solaris X.
When I execute it I get the following
# sh ALU_SOL_SET_HOST_SCRIPT.sh
ALU_SOL_SET_HOST_SCRIPT.sh: ^M: not found
ALU_SOL_SET_HOST_SCRIPT.sh: ^M: not found
cd /var/tmp/
ALU_SOL_SET_HOST_SCRIPT.sh: /var/tmp/^M: does not exist
When I open the script with vi I can see the ^M argument @ every line.I am not sure whether the ^M argument is the problem here.I guess I will remove it and check but I would like your professional opinion on the matter.Is the ^M symbol supposed to show up in vi on every line?
If i do just a regular cat ALU_SOL_SET_HOST_SCRIPT.sh it doesnt show any ^M symbols.
# cat ALU_SOL_SET_HOST_SCRIPT.sh
#!/bin/sh
###########################################################
############################################################
set -x
cd /var/tmp/
echo "######################################################" > /var/tmp/configure_hostname.log
echo "CENSORED STUFF" >> /var/tmp/configure_hostname.log
echo "######################################################" >> /var/tmp/configure_hostname.log
DOMAIN=`/CENSORED STUFF "ALL_SYSTEM_DOMAIN"`
if [ "$?" != 0 ]; then
echo "Couldn't find ALL_SYSTEM_DOMAIN custom attribute" >> /var/tmp/configure_hostname.log
exit 1
fi
if [ ${DOMAIN} = 1 ]; then
echo "ALL_SYSTEM_DOMAIN custom attribute is not set properly" >> /var/tmp/configure_hostname.log
exit 1
fi
HOSTNAME=`/CENSORED STUFF "ALL_SYSTEM_HOSTNAME"`
if [ "$?" != 0 ]; then
echo "Couldn't find ALL_SYSTEM_HOSTNAME custom attribute" >> /var/tmp/configure_hostname.log
exit 1
fi
if [ ${HOSTNAME} = 1 ]; then
echo "ALL_SYSTEM_HOSTNAME custom attribute is not set properly" >> /var/tmp/configure_hostname.log
exit 1
fi
IP=`CENSORED STUFF "ALL_NETWORK_PRD_IP"`
if [ "$?" != 0 ]; then
echo "Couldn't find ALL_NETWORK_PRD_IP custom attribute" >> /var/tmp/configure_hostname.log
exit 1
fi
if [ ${IP} = 1 ]; then
echo "ALL_NETWORK_PRD_IP custom attribute is not set properly" >> /var/tmp/configure_hostname.log
exit 1
fi
#1. Configure /etc/hosts
echo "/etc/hosts:" >> /var/tmp/configure_hostname.log
cp /etc/hosts /var/tmp/hosts.sav
echo "#" > /etc/hosts
echo "# Internet host table" >> /etc/hosts
echo "#" >> /etc/hosts
echo "::1 localhost" >> /etc/hosts
echo "127.0.0.1 localhost" >> /etc/hosts
echo "${IP} ${HOSTNAME} ${HOSTNAME}.${DOMAIN}" >> /etc/hosts
cat /etc/hosts >> /var/tmp/configure_hostname.log
echo "######################################################" >> /var/tmp/configure_hostname.log
#2. configure hostname
echo "hostame:" >> /var/tmp/configure_hostname.log
echo "${HOSTNAME}" > /etc/nodename
hostname ${HOSTNAME}
echo `hostname` >> /var/tmp/configure_hostname.log
echo "######################################################" >> /var/tmp/configure_hostname.log
#3. configure other files
cp /etc/hosts /etc/inet/hosts
# restart network service
svcadm restart network/physical >> /var/tmp/configure_hostname.log
echo "######################################################" >> /var/tmp/configure_hostname.log
# force to update SA DB with latest info
/CENSORED STUFF/pylibs/cog/bs_hardware >> /var/tmp/configure_hostname.log
/CENSORED STUFFpylibs/cog/bs_software >> /var/tmp/configure_hostname.log
echo "######################################################" >> /var/tmp/configure_hostname.log
echo "END PROCESS" >> /var/tmp/configure_hostname.log
echo "######################################################" >> /var/tmp/configure_hostname.log
Last edited by dann_radkov; 09-13-2011 at 02:27 PM.
Reason: typo
|