Skip to content

Instantly share code, notes, and snippets.

@msonnabaum
Created June 1, 2011 12:57
Show Gist options
  • Save msonnabaum/1002240 to your computer and use it in GitHub Desktop.
Save msonnabaum/1002240 to your computer and use it in GitHub Desktop.
<?php
/**
* @file
*/
function ssh_drush_command() {
$items['ssh-blah'] = array(
'description' => '',
'arguments' => array(
'site-alias' => 'A site alias',
),
'options' => array(
),
'examples' => array(
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
);
return $items;
}
/**
* Command callback.
*/
function drush_ssh_blah($alias) {
$site = drush_sitealias_get_record($alias);
$hostname = isset($site['remote-host']) ? drush_escapeshellarg($site['remote-host'], "LOCAL") : null;
$username = isset($site['remote-user']) ? drush_escapeshellarg($site['remote-user'], "LOCAL") . "@" : '';
$ssh_options = isset($site['ssh-options']) ? $site['ssh-options'] : drush_get_option('ssh-options', "-o PasswordAuthentication=no");
if (!is_null($hostname)) {
$cmd = "ssh " . $ssh_options . " " . $username . $hostname . " " . drush_escapeshellarg($command, "LOCAL");
}
proc_close(proc_open($cmd, array(0 => STDIN, 1 => STDOUT, 2 => STDERR), $pipes));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment