Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bash shell function commands not executing ..?

Status
Not open for further replies.

rigstars2

Instructor
Dec 18, 2011
64
US
This function is supposed to receive a variable $CON and start a service. I tested it and so I know the function is processing the $CON variable however, when I check the service, it was still down. If run the last line in the function by itself in commandline, it starts the service fine. Do I need to enclose the commands below in ticks or quotes ..

restart_con()
{
cd /nfs/informatica_pwx/logs/$CON/condenser/
rm -rf nohup.out
nohup pwxccl cs=pwxccl_$CON.cfg config=/nfs/informatica_pwx/logs/$CON/listener/$CON_dbmover.cfg &

# below echo's the variable passed in successfully
echo $CON
}

 
This function is supposed to receive a variable $CON
How ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I pass the variable like this below from another function ..


chk_con() {
DB=`ps -ef | grep pwxccl | grep $CON | cut -d\/ -f5`
[[ $DB == $CON ]] && echo "${bold}'$CON' condenser already running${normal}" || restart_con $CON
exit
}
 
any ideas? I know the problem is not the parameter as it is being passed and used correctly.
 

It is still not clear where $CON comes from.
Also, you sure $DB is computed correctly?
[3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
print $CON first to see if it's really being passed. This applies to any sub you have.

Code:
restart_con()
{
# below echo's the variable passed in successfully
echo $CON

#cd /nfs/informatica_pwx/logs/$CON/condenser/
#rm -rf nohup.out
#nohup pwxccl cs=pwxccl_$CON.cfg config=/nfs/informatica_pwx/logs/$CON/listener/$CON_dbmover.cfg &
}
 
yes, $DB is computed correctly. The problem is here, I can copy and paste this same command in the terminal and gets executed but will not work in the script ..
I tried putting it in command substitution both ways and still doesn't work ..
I read on forums that nohup has trouble executing in scripts ..

nohup $(pwxccl cs=pwxccl_$CON.cfg config=/nfs/informatica_pwx/logs/$CON/listener/$CON_dbmover.cfg) &

and

nohup `pwxccl cs=pwxccl_$CON.cfg config=/nfs/informatica_pwx/logs/$CON/listener/$CON_dbmover.cfg` &

 
What is the content of /nfs/informatica_pwx/logs/$CON/condenser/nohup.out after the script execution ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top