Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


bash shell function commands not executing ..?

bash shell function commands not executing ..?

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 ..

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

RE: bash shell function commands not executing ..?

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

RE: bash shell function commands not executing ..?

any ideas? I know the problem is not the parameter as it is being passed and used correctly.

RE: bash shell function commands not executing ..?

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

The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: bash shell function commands not executing ..?

print $CON first to see if it's really being passed. This applies to any sub you have.


# 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 &

RE: bash shell function commands not executing ..?

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) &


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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close