Adding script to generate ISBN file and FTP it to our vendor.
authorChris Sharp <csharp@georgialibraries.org>
Tue, 29 Apr 2014 19:32:55 +0000 (15:32 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Tue, 29 Apr 2014 19:32:55 +0000 (15:32 -0400)
novelist-isbns.sh [new file with mode: 0644]

diff --git a/novelist-isbns.sh b/novelist-isbns.sh
new file mode 100644 (file)
index 0000000..bd34850
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# A script to export ISBNs from PINES records for NoveList Select OPAC Integration
+WORKDIR="$PWD"
+OUTBOX="$WORKDIR/outbox"
+OUTFILE="pines_isbns_`date +%F`.csv"
+OUTPATH="$OUTBOX/$OUTFILE"
+DB_USER="mydbusername"
+DB_NAME="mydbname"
+FTP_ADDR="ftp.example.com"
+FTP_PATH="remote/path"
+FTP_USER="myftpuser"
+FTP_PASS="myftppass"
+EBSCO_EMAIL="Support@vendor.com"
+ADMIN_EMAIL="my-admins@mylibrarysystem.org"
+EMAIL_SUBJECT="ISBN Update - galileo (for PINES)"
+
+echo "`date`"
+if [ ! -d "$OUTBOX" ]; then
+        mkdir $OUTBOX
+        echo "Creating directory $OUTBOX."
+fi
+
+psql -U $DB_USER -o $OUTPATH -A -t -c "select isbn from reporter.materialized_simple_record rmsr join biblio.record_entry bre on (rmsr.id = bre.id and not bre.deleted) where isbn is not null and isbn <> '{NULL}'" $DB_NAME
+sed -i "s/[{}]//g" $OUTPATH
+sed -i "s/,/\n/g" $OUTPATH
+cd $OUTBOX
+pftp -n -v $FTP_ADDR <<EOT
+user $FTP_USER $FTP_PASS
+cd $FTP_PATH
+put $OUTFILE
+bye
+EOT
+
+echo "PINES ISBN upload completed for `date +%F`" | mutt -s "$EMAIL_SUBJECT" -c "$ADMIN_EMAIL" "$EBSCO_EMAIL"
+