Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to restart CACHE(database that I am using) Instance from shell script. What I did is created a function in the shell script named resatrt_cache.

restart_cache()
{
 ccontrol stop instancename restart
}

This command is running but the control goes to cache and while stopping cache it get stuck to this question

**Do you want to broadcast a message to anyone? No =>**

How can I pass the value here through shell script

share|improve this question

1 Answer 1

On the assumption that it takes input from stdin, and you want to answer "no":

restart_cache() {
    ccontrol stop instancename restart << EOF
no
EOF
}

Note: the indentation is important.

If you want to answer "no" to any and all prompts, you can use yes instead:

restart_cache() {
    yes no | ccontrol stop instancename restart
}

If you'd rather accept the defaults (and the program takes a line feed to mean that), use yes ''.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.