0

I want to execute this SQL line:

select * from "foo" where name='bar'

I call above line "sql_line" in the next statements.

Now I want to call this via psql:

psql -c sql_line

Now I want to call this via ssh:

ssh remote-host psql -c sql_line

How to quote this, to get it right?

I tried this, but this fails:

ssh remote-host psql -c "select * from \"foo\" where name='bar'"

I am using GNU bash, Version 4.3.48

  • Why do we need to do with ssh in particular? cant we configure remote acces in psql? – msp9011 Sep 5 '18 at 11:41
  • @SivaPrasath this does not work. The bash thinks the statement is not finished yet. It displays > after I am hitting enter. – guettli Sep 5 '18 at 12:13
  • @SivaPrasath ssh is needed. A firewall is blocking direct connections to the DB. – guettli Sep 5 '18 at 14:33
  • check : stackoverflow.com/questions/48127483/… – msp9011 Sep 5 '18 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.