krang_exec - run some piece of code under the Krang install
Run an external script
$ krang_exec < script.pl
Run a simple command
$ krang_exec -e "print $ENV{KRANG_INSTANCE}"
Run an SQL query and print the results
$ krang_exec -qpe "SELECT COUNT(*) FROM story"
Sometimes it's extremely useful to be able to run a script or command for each installed instance of Krang. This makes it really easy to do so. It takes care of making sure all the paths to libraries are setup correctly, addons are loaded and other niceties.
By default it executes what's coming from STDIN.
perl's
-e, it's really only useful for short quick things.
perl's -M option, loads a module after setting up the paths
and environment.
perl's -M option, loads an Krang module after setting up the paths
and environment. You don't need to specify the 'Krang::' prefix of the module either.
Although it won't hurt anything.
-p option
if you want to actually see the results of the query.