homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

Finding Wordpress sites
Script to find all Wordpress sites on a Parallels Pro box

 6:43 pm on Feb 11, 2009 (gmt 0)

We've gotten to a point where we have a ton of customers using Wordpress, and we want to make sure they're all up to date without having to login to each backend to see what version's running.

I can easily run
locate /wp-includes/version.php
to get a list of all the sites that have Wordpress installed.

What I really want to do is find the actual domain name and the version of Wordpress being run so I know which sites need an upgrade.

Forgive me if I'm being dense about this, but here goes.

What I have now is a text file that looks like this.

I want to run through that list and grep that sitenum from the /etc/virtualhosting/mappings/domainmap so I can get the actual domain names. What's happening to me though, is that when the shell script greps for "site3" it's also finding site31, site32, site33 and so on.

My shell script is very simple and isn't at all accomplishing what I intended. I know there's a better way to do it, but I'm not a programmer!

This is what I have now:

for i in `cat sitenums`;
grep -F $i /etc/virtualhosting/mappings/domainmap;

And the result is that almost every domain name is being displayed for the reason I gave above.

Does anyone have a better idea about how I should do this?

Any suggestions will be greatly appreciated.




 12:50 am on Feb 24, 2009 (gmt 0)

I've never used Parallels pro and I'm unsure what the exact format of the /etc/virtualhosting/mappings/domainmap is but the following may work:

for i in `cat sitenums`;
grep $i[^0-9] /etc/virtualhosting/mappings/domainmap;

The $i[^0-9] should match any line that contains the output of the sitenums file not followed by a number.

I've run a test and it seems to work:
[root@TEST htdocs]$ cat test2.txt
[root@TEST htdocs]$ cat test3.txt
site3 alpha
site31 beta
site32 charle
site33 delta
[root@TEST htdocs]$ cat shell.txt
for i in `cat test2.txt`;
grep $i[^0-9] test3.txt;
[root@TEST htdocs]$ ./shell.txt
site3 alpha


 2:27 am on Mar 1, 2009 (gmt 0)

Looks like you are using Ensim?

It has a command line tool

sitelookup -a domain
to get a list of all domains

Maybe something like this will work:

sites=`sitelookup -a site_root¦sort`;for s in $sites;do find $s/var/www/html -type d -name wp-includes;done

That's a pipe to sort...to put them in alphabetical order for you.


 2:55 am on Mar 1, 2009 (gmt 0)

Thanks. I'll give it a try.


 10:05 pm on Mar 3, 2009 (gmt 0)

did that work for you?


 11:06 pm on Mar 3, 2009 (gmt 0)

I never got to try it. Someone from another forum wrote out a perl script that would get the information I needed. I have to learn how to program at some point!


 11:18 pm on Mar 3, 2009 (gmt 0)

I think it will do it. I like these simple one-liners. I use a ton of them for various tasks. Learning how to do a bash loop is useful for anyone working at the command line on Linux.


 12:12 am on Mar 4, 2009 (gmt 0)

I need to ask about your services. I wanted to get someone to upgrade one server from Ensim Pro 10.3.0 to 10.3.3. Is it ok to ask about that here?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved