[wp-hackers] Getting list of plugins from shell script
Harish Narayanan
harish.mlists at gmail.com
Tue Aug 3 09:28:42 UTC 2010
On 8/3/10 1:26 PM, Scot Hacker wrote:
> Kind of obscure, but wondering if anyone has a script or command that can be used to derive a list of active plugins from the shell (not from PHP). I have this so far:
>
> # Get list of active plugins from db
> raw_plugins_sql="SELECT option_value FROM $dbname.wp_options WHERE option_name = 'active_plugins';"
> echo $raw_plugins_sql
> mysql -u root -e "$raw_plugins_sql" -p$root_db_pass $dbname
>
> But the output is really messy and I can't seem to get any further with it (this is part of a script where I'm trying to get a per-site listing of active plugins used on each site on a server). Maybe need an awk expert here :)
This was a fun exercise, and the bash script works on the two sites that
I tried it in.
export retrieve_active_plugins="SELECT option_value FROM wp_options
WHERE option_name = 'active_plugins';"
mysql -u uname -e "$retrieve_active_plugins" -h hostname -p dbname \
| grep '{' \
| sed -e 's/i:[0-9]\+;s:[0-9]\+:"/\n/g' \
| egrep -v 'a:[0-9]+' \
| sed -e 's/";//g' \
| sed -e 's/\}//g'
I've broken this up into multiple lines (at each '\') to make it a
little easier to read, but it should be in one line. Another fun
exercise to figure out what each line does!
Harish
Harish
More information about the wp-hackers
mailing list