0
Friends, I have the difficulty of creating a script to perform an UPDATE in a database connecting via ssh being outside the server follows below my code.
Commando:
ssh hostname 'psql -d database -U usuario --command="select host,name,phone_number,active from trunks where id = '22'"'
Upshot:
host | name | phone_number | active
--------------+---------------------+--------------+--------
100.200.1.5| teste | 0000222 | t
(1 registro)*
Ok, for select but I’m having trouble treating the 'Quotes' to make a UPDATE
or ALTERTABLE
could help me how to treat quotes in the command follows the feedback I have.
Commando:
ssh hostname 'psql -d database -U usuario --command="update trunks set active = 't' where id = '22'"'
Error
ERROR: column "t" does not exist
LINHA 1: update trunks set active **= t** where id = 22
It says the T column doesn’t exist but T is the parameter FALSE / TRUE
even if I quote ' ' does not recognize could help me.
I intend to execute this command from within a variable today I can run pro select, but for update I have this problem that I mentioned. result=$(ssh hostname '"(
psql -d database -U usuario -A -t --command="select host,name,phone_number,active from trunks where id = '$LINHA';"
"');– Victor
As you use ' to delimit your psql command then duplicate the internal ' : ssh hostname 'psql -d database -U user --command="update Trunks set active = '’t'' Where id = ''22''"', two ' and not one ".
– anonimo
put duplicate but now returns error sitaxe ERROR: syntax error at or near ";" LINE 1: update Trunks set active = t Where id = ;
– Victor