Created
May 14, 2011 14:19
-
-
Save hideo55/972254 to your computer and use it in GitHub Desktop.
Login to MySQL shell on DotCloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl -w | |
use strict; | |
use IPC::Cmd qw/run/; | |
use IPC::System::Simple qw(systemx); | |
die "You must provide deploy name as argument" unless scalar(@ARGV) > 0; | |
my $deploy_name = $ARGV[0]; | |
my ($ok, $err, undef, $stdout) = run( | |
command => ['dotcloud', 'info',$deploy_name], | |
timeout => 30, | |
); | |
die "Can't get information from DotCloud ($err)" unless $ok; | |
my ($dotcloud_info) = @$stdout; | |
my ($pw) = $dotcloud_info =~ m{url:\s*mysql://root:(.*?)\@}; | |
die "The deploy($deploy_name) is not MySQL" unless $pw; | |
my $cmd_args = ['run', $deploy_name, '--', 'mysql', '-uroot', qq{'-p$pw'}]; | |
systemx('dotcloud', @$cmd_args); | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment