Skip to content

Instantly share code, notes, and snippets.

@hideo55
Created May 14, 2011 14:19
Show Gist options
  • Save hideo55/972254 to your computer and use it in GitHub Desktop.
Save hideo55/972254 to your computer and use it in GitHub Desktop.
Login to MySQL shell on DotCloud
#!/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