ruby/ssh/sqlite3 shell转义
我需要一行/一块ruby代码来执行以下操作:ruby/ssh/sqlite3 shell转义,ruby,ssh,sqlite,escaping,Ruby,Ssh,Sqlite,Escaping,我需要一行/一块ruby代码来执行以下操作: 启动特定用户/主机的ssh外壳:dev@localhost 在该ssh shell中,在给定文件上启动sqlite3会话:/home/dev/current/b/test.sqlite3 执行sql的给定行:updatecustomers set mode=“Y” 我把所有的元素都放在一起了。我可以启动ssh shell,我可以让shell启动sqlite3,我可以让sqlite3执行一行sql 我的问题是试图逃避所有不同层次的引用 在得到建议之
- 启动特定用户/主机的ssh外壳:
dev@localhost
- 在该ssh shell中,在给定文件上启动sqlite3会话:
/home/dev/current/b/test.sqlite3
- 执行sql的给定行:
updatecustomers set mode=“Y”
Peter。要在远程服务器上运行的Shell命令:
sqlite3 /home/dev/current/b/test.sqlite3 "update customers set mode = 'Y';"
ssh dev@localhost \
"sqlite3 /home/dev/current/b/test.sqlite3 \"update customers set mode = 'Y';\""
要在本地运行的Shell命令,以便在远程服务器上运行上述命令:
sqlite3 /home/dev/current/b/test.sqlite3 "update customers set mode = 'Y';"
ssh dev@localhost \
"sqlite3 /home/dev/current/b/test.sqlite3 \"update customers set mode = 'Y';\""
要运行上述shell命令,请运行Ruby命令:
system "ssh dev@localhost \\\n"\
' "sqlite3 /home/dev/current/b/test.sqlite3 '\
'\\"update customers set mode = \'Y\';\\""'
(为了避免在这些代码示例中出现水平滚动,我添加了免费的换行符(从而免费转义换行符)。我不熟悉sqlite。如果您告诉我您试图运行的sqlite3命令,我可以告诉您如何在ssh命令中转义它。@dave4420可以作为
sqlite3/home/dev/current/b/test.sqlite3“update customers set mode='Y';”
或echo“update customers set mode='Y';“| sqlite3/home/dev/current/b/test.sqlite3
。