6

Is there a way to use drush to compare the list of running modules on two Drupal 6 sites?

I have two sites running locally (with two code bases if that matters) with different modules, but a very similar odd problem (discussed about here). In trying to find the modules that might causing this problem, it would be really helpful to get a list of modules that are running on both sites.

7

I don't know if there is a direct way, but this should work with bash or a similar shell. No idea about how to do that with Windows :) Please comment and I'll integrate it into the answer.

First, save the enabled modules of both sites into a textfield with this command:

drush pm-list --status=enabled > enabled_modules_site_x.txt

Then, you can easily compare the output of these two files with diff.

diff first_file second_file
  • I always like the obvious solution that eludes me. This gets me close enough. In Windows you can use Notepad++ to do the diff. The only problem I'm having is the for some reason I'm getting white space differences between the two files that make the diff much more complex than it should be. But it's good enough to work with. – acrosman May 5 '11 at 18:43
  • You can additionally use the --pipe argument to only get the module name per line, should get rid of those whitespaces I guess but you can't compare the version. – Berdir May 5 '11 at 18:59
  • You can also do diff using Sublime Text as well – pal4life Jul 18 '14 at 20:45
2

Here is my adaptation:

diff -b -s --suppress-common-lines <(drush @sa1 pm-list --status=enabled --fields=package,name) <(drush @sa2 pm-list --status=enabled --fields=package,name)

It doesn't care about versions to get a quick overview of which modules haven't been enabled on the other server.

1

Berdir's answer works, mostly, but there is a more direct way to do it, and you can compare across multiple machines if you have drush aliases set up to allow it.

diff -b -s --suppress-common-lines --side-by-side <(drush @uat pm-list --status=enabled) <(drush @dev pm-list --status=enabled)

(Obviously you need to replace @uat and @dev with the aliases that are appropriate in your case.)

You normally only care about the differences, so --suppress-common-lines is a useful option. I find it easier to see differences when they are side-by-side, so the --side-by-side option may be helpful to you too. Remove it if you prefer standard diff output. -b ignores whitespace differences, which is very handy. -s tells you if the results are identical, which is nice to get feedback about, rather than the default, which is diff saying nothing if there are no differences.

This isn't guaranteed to always work perfectly, however, because under certain conditions you might get your output formatted differently between the two servers.

It should, however, get you most of the way to a very quick and easy, single-step, way of comparing enabled modules on two Drupal installations, that works in 95% of cases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.