PostgreSQL 9.2 – Configuring plsh extension

PostgreSQL 9.2 – Configuring plsh extension

This extension allows you to run shell commands from within the database which are useful for moving or renaming files in the Unix level. The GitHub repository is over here. Below is a quick guide on how I get it up and running.

Create an auxiliary directory to hold the files.

# mkdir /tmp/plsh
# cd /tmp/plsh

Download and extract the tar files

# wget https://github.com/petere/plsh/archive/1.20130823.tar.gz
# tar xvf 1.20130823.tar.gz
# cd 1.20130823.tar.gz

Install gcc and postgresql92 in order to compile plsh.

# yum install postgresql92-devel.x86_64
# yum install gcc
# make PG_CONFIG=/usr/pgsql-9.2/bin/pg_config
# make install PG_CONFIG=/usr/pgsql-9.2/bin/pg_config

Create plsh extension. (This needs to be done on each database which requires plsh)

# psql weishan
weishan=# create extension plsh;

Verify that the plsh extension has been installed correctly.

weishan=# \dx
 List of installed extensions
 Name | Version | Schema | Description
---------+---------+------------+------------------------------
 plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
 plsh | 2 | public | PL/sh procedural language

Cheers,
Wei Shan

Advertisements

One thought on “PostgreSQL 9.2 – Configuring plsh extension”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s