The reason the password is echoing originally is because Capistrano
isn't prompting you--it's just echoing the text from the server, which
happens to be a prompt. If you want to be able to enter the password
when the server prompts, you need to be willing to do a bit more work:
run "mysql -u root blah blah blah" do |ch, stream, data|
if data =~ /Enter password:/
ch.send_data(root_db_password)
end
end
You're basically setting up an expect-like negotiation, checking the
output from the server for what looks like a prompt, and then sending
the password in response when you see it.
I'd definitely be interested in a patch that simplified the
expect-like interactions. I've not needed it much myself, but I know
it's been a frequent pain-point on this list.
- Jamis
On 9/14/07, meSleepy <[EMAIL PROTECTED]> wrote:
>
> Thanks KY,
>
> This gives me some good ideas. I will post the results. I am going to
> try this later, at the moment I am taking Monit for a spin - so there
> goes a few hours at least. Keep you posted.
>
> - meSleepy
>
> On Sep 15, 2:31 pm, ky <[EMAIL PROTECTED]> wrote:
> > if you include this:
> >
> > set(:root_db_password) do
> > Capistrano::CLI.password_prompt "Root DB Password?: "
> > end
> >
> > then your task would be:
> > task :before_migrate, :roles => :db do
> > run "mysql -u root -p #{root_db_password}"
> > end
> >
> > ...which is actually a 1/2-assed solution b/c then your command will
> > immediately echo your carefully hidden password. Lmk if you figure
> > out how to not echo the command.
> >
> > btw, you may've already figured this out, but I find it handy to use
> > here strings to get commands to mysql -- like:
> > run "mysql -u root -p #{root_db_password} <<< \"create database
> > my_prod_db character set utf8;\""
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---