我在通过 SSH 远程执行命令时遇到问题。我正在尝试下面。
ssh xx.xx.xx.xx "psql -U qradar -c "select count(id) from offense_view where to_timestamp(start_time/1000) > NOW() - interval '180 minutes'"
它给出了如下错误:
Pseudo-terminal will not be allocated because stdin is not a terminal. ERROR: syntax error at or near "180" LINE 1: ... to_timestamp(start_time/1000) > NOW() - interval 180 minute...
最佳答案
问题是您使用双引号来分隔命令中 ssh
的参数以及 psql
的参数。这会导致您的字符串被错误地解析。您还缺少 psql
命令的结尾双引号。
在 shell 中嵌套引号很棘手,当您使用 ssh
时就更难了。如果您使用此处文档会更容易。
ssh xx.xx.xx.xx <<EOF
psql -U qradar -c "select count(id) from offense_view where to_timestamp(start_time/1000) > NOW() - interval '180 minutes'"
EOF
关于linux - 为什么当我尝试远程执行命令时出现错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54935900/