Quoting of SQL excuted via psql via ssh

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












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










share|improve this question





















  • Why do we need to do with ssh in particular? cant we configure remote acces in psql?
    – msp9011
    Sep 5 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 at 12:13










  • @SivaPrasath ssh is needed. A firewall is blocking direct connections to the DB.
    – guettli
    Sep 5 at 14:33










  • check : stackoverflow.com/questions/48127483/…
    – msp9011
    Sep 5 at 14:39














up vote
0
down vote

favorite












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










share|improve this question





















  • Why do we need to do with ssh in particular? cant we configure remote acces in psql?
    – msp9011
    Sep 5 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 at 12:13










  • @SivaPrasath ssh is needed. A firewall is blocking direct connections to the DB.
    – guettli
    Sep 5 at 14:33










  • check : stackoverflow.com/questions/48127483/…
    – msp9011
    Sep 5 at 14:39












up vote
0
down vote

favorite









up vote
0
down vote

favorite











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










share|improve this question













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







shell quoting






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 5 at 11:27









guettli

118520




118520











  • Why do we need to do with ssh in particular? cant we configure remote acces in psql?
    – msp9011
    Sep 5 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 at 12:13










  • @SivaPrasath ssh is needed. A firewall is blocking direct connections to the DB.
    – guettli
    Sep 5 at 14:33










  • check : stackoverflow.com/questions/48127483/…
    – msp9011
    Sep 5 at 14:39
















  • Why do we need to do with ssh in particular? cant we configure remote acces in psql?
    – msp9011
    Sep 5 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 at 12:13










  • @SivaPrasath ssh is needed. A firewall is blocking direct connections to the DB.
    – guettli
    Sep 5 at 14:33










  • check : stackoverflow.com/questions/48127483/…
    – msp9011
    Sep 5 at 14:39















Why do we need to do with ssh in particular? cant we configure remote acces in psql?
– msp9011
Sep 5 at 11:41





Why do we need to do with ssh in particular? cant we configure remote acces in psql?
– msp9011
Sep 5 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 at 12:13




@SivaPrasath this does not work. The bash thinks the statement is not finished yet. It displays > after I am hitting enter.
– guettli
Sep 5 at 12:13












@SivaPrasath ssh is needed. A firewall is blocking direct connections to the DB.
– guettli
Sep 5 at 14:33




@SivaPrasath ssh is needed. A firewall is blocking direct connections to the DB.
– guettli
Sep 5 at 14:33












check : stackoverflow.com/questions/48127483/…
– msp9011
Sep 5 at 14:39




check : stackoverflow.com/questions/48127483/…
– msp9011
Sep 5 at 14:39















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f466991%2fquoting-of-sql-excuted-via-psql-via-ssh%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f466991%2fquoting-of-sql-excuted-via-psql-via-ssh%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay