使用引号中的引号通过 bat 中的 plink 执行 psql

Executing psql through plink within a bat using quotes within quotes

提问人:Juan Lucarte 提问时间:10/24/2019 最后编辑:Juan Lucarte 更新时间:10/24/2019 访问量:188

问:

在蝙蝠中执行的这个简单更新不起作用。

@echo off
plink -pw passcode [email protected] "psql -U sa DATABASE -c 'update users set username = 'Last_Name' where iduser = 12345'"

这个想法是从他的命令行在远程 linux 服务器中执行 psql 更新。我知道问题与如何将引号设置为Last_Name分配给 char 列用户名的 char 值有关,但我不知道 scape 字符的正确顺序。

PostgreSQL 批处理文件 psql 报价 plink

评论

0赞 azbarcea 10/24/2019
你的逃生顺序很好。在“(双引号)中,您可以随心所欲地使用”(单引号)。

答:

1赞 Ed Bangga 10/24/2019 #1

用 Backlash 字符转义你的字符串。sql

@echo off
plink -pw passcode [email protected] "psql -U sa DATABASE -c \"update users set username = 'Last_Name' where iduser = 12345\""