![]() I presume that you want to pick up the value of $DB from the remote machine rather than the local machine.ĭoes that get you anywhere? If you want to just dummy run it, add an echo just before the sudo within the quotes (of whatever type) and it should show you what it would run on the remote machine. They are variations to try passing quotes and/or quoted text. Ssh -o StrictHostKe圜hecking=no "sudo psql -U postgres -c \"select pg_terminate_backend(pid) from pg_stat_activity where datnam= \"\$DB \" \"" # Which seems to work okay if I insert an echo before the sudo (because I don't have postgress installed on my local machine. debug1: channel 3: new direct-tcpip debug1: channel 3: free: direct-tcpip: listening port 5433 for. ![]() a normal operation looks like this: debug1: Connection to port 5433 forwarding to localhost port 5432 requested. Ssh -o StrictHostKe圜hecking=no "sudo psql -U postgres -c \"select pg_terminate_backend(pid) from pg_stat_activity where datnam= \\\"\$DB \\\" \"" # extra escaping so that the quoted string passed ends up as \"$DB\" to the remote shell. Then, you may also consider adding -v (or even -vvv) to your ssh command - it'll spew a lot of useful debug information, e.g. This is equivalent to specifying dbname as the first non-option argument on the command line. Specifies the name of the database to connect to. The following command-line options control the database connection parameters.-d dbname-dbnamedbname. Ssh -o StrictHostKe圜hecking=no "sudo psql -U postgres -c \"select pg_terminate_backend(pid) from pg_stat_activity where datnam= \"\$DB \" \"" # backslash and two double quotes at the end, escaping the $ for the DB name Show help about pgdump command line arguments, and exit. Ssh -o StrictHostKe圜hecking=no 'sudo psql -U postgres -c \'select pg_terminate_backend(pid) from pg_stat_activity where datnam=$DB \'' # backslash and two single quotes at the end Code : ssh -o StrictHostKe圜hecking=no 'sudo psql -U postgres -c "select pg_terminate_backend(pid) from pg_stat_activity where datnam=\'$DB\' "'" ' # Wrapping it all in single quotes should pass the double quotes, but you may need to escape the single quotes within the double quotes
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |