Created
June 4, 2020 09:41
-
-
Save alex-moreno/45f10359a18a900e3574d461bed46fe2 to your computer and use it in GitHub Desktop.
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
/** | |
* Execute drush to fetch users and roles in a given site. | |
* | |
* @param [type] $site_alias | |
* @param [type] $drush_alias | |
* @return void | |
*/ | |
function execDrushUserInfo($site_alias, $drush_alias) | |
{ | |
$php = "/usr/local/bin/php"; | |
$drush_php = "/usr/local/bin/drush"; | |
$result = exec("drush $drush_alias -l $site_alias uinf \"$(drush $drush_alias -l $site_alias sqlq \"SELECT GROUP_CONCAT(name) FROM users_field_data\")\"", $output, $return); | |
if (strpos($output[2], "Command user-information was not found. Drush was unable to query the database")) { | |
echo "\nCould not query database in $site_alias \n "; | |
} else { | |
echo "\nUsers found in $site_alias \n"; | |
print_r($result); | |
print_r($output); | |
} | |
} | |
// Execute drush example. | |
execDrush("sites_url_alias.com", " status ", " @drushalias.01dev "); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment