Re: psql remote shell command

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Dennis <dennisr(at)visi(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: psql remote shell command
Date: 2016-06-02 23:48:37
Message-ID: CAKFQuwZ1J1KAJdjaBR-ucpbKKd1pfEo2fPkHJ6+Swj7dNpYy3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jun 2, 2016 at 7:39 PM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:

> On Fri, Jun 3, 2016 at 8:30 AM, Dennis <dennisr(at)visi(dot)com> wrote:
> > Is it possible to execute command in on system the is hosting postgresql
> > remotely using psql or other mechanism? I know I can use \! in psql but
> > that executes the commands on the host where I am running psql from.
> Also,
> > is it possible for a postgres login/user to stop or restart a running
> > postgres instance from in side psql or similar client. e.g. psql -c
> “pg_ctl
> > stop -D some_data_dir”
>
> Not directly. You could implement an extension that wraps a function
> available at SQL level taking some actions, however for the restart
> the error handling is tricky if you just have control via psql. How
> could you start a node that has been stopped during a restart but
> could not boot up. Take the example of an incorrect parameter value
> that has been added when the node was up via ALTER SYSTEM...
>

​I was focused on admin task due to the pg_ctl (not sure you'd want to run
that via psql...) but if you have shell script applications you want to run
you could consider:

https://github.com/petere/plsh

​I used it a while back successfully but have since gone a more
conventional route by embedding psql in shell and not the other way around.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2016-06-02 23:54:07 Re: psql remote shell command
Previous Message David G. Johnston 2016-06-02 23:42:48 Re: psql remote shell command