One of the initial reasons for setting up this blog was to share with the community many of the extra scripts and tools that MVLC has developed for working with Evergreen. Most of these are publicly available on our git server in various repositories and branches. This post is going to be about the current state of our evergreen_utilities repository.
This repository contains some handy utility scripts for use with Evergreen. They are written against master and kept relatively up to date with changes there. They may work with earlier releases of Evergreen, but we make no guarantees. In many cases they will need extensive modifications to work with anything but the most recent releases or master.
There are currently four scripts in the repository. (More will be added in the future and will eventually get a blog post when added.)
- copy_delete_from_copy_bucket.pl
- This script deletes copies from the system that are found in copy buckets. You run it with a list of bucket ids on the command line and it will delete the copies in those buckets.
- copy_delete_from_csv.pl
- This script takes a CSV file as input. If the first column of each row is a copy barcode, it will delete that copy from the database.
- json_query.pl
- This script takes a json query file as input, runs that query and then outputs the results to standard output in a CSV format.
- parameters.pl
- This script will create a XLS file with multiple sheets containing your main in-database parameters for circulation and holds.
Most of these scripts use a custom JSONPrefs module in order to load settings or login information for Evergreen.
The scripts generally look for these files in a myprefs.d subdirectory of the current user's home. The most common such file is expected to be named evergreen.json and to contain a JSON object with fields containing login credentials for Evergreen. Here is a sample of what that might look like:
{
"username" : "eguser",
"password" : "egpassword",
"workstation" : "egworkstation",
"type" : "staff"
}
You, of course, replace eguser, egpassword, and egworkstation with the credentials appropriate to your system.
The parameters.pl script needs a JSON file of properties to get access to your database server via Perl DBI:
{
"database" : "dbname",
"host" : "hostname",
"port" : "portnumber",
"user" : "username",
"password" : "password"
}
The host and port parameters are optional if your DBI does not need them to connect to a database running on the localhost. For the most part, I would recommend that you fill them in.
The locations for finding these JSON files is currently hardcoded, but future development my make it more dynamic. Patches welcome!
No comments:
Post a Comment