sqlite3 sshコマンドに問題があります(引用符が間違っていると仮定します)。

sqlite3 sshコマンドに問題があります(引用符が間違っていると仮定します)。

以下はうまくいきます。

ssh plxch1035.pdx.xxxxxx.com "sqlite3 /p/hdk/rtl/proj_data/shdk74/fe_data/ipci/ipci.db 'select * from tools'"

特定のツール行が必要な場合:

ssh plxch1035.pdx.xxxxxx.com "sqlite3 /p/hdk/rtl/proj_data/shdk74/fe_data/ipci/ipci.db 'select * from tools where name='bscan''"

エラーは次のとおりです。

SQL error: no such column: bscan

カラム名 has の存在を確認しましたbscan

私の引用符がめちゃくちゃだと仮定し、周囲の一重引用符をエスケープしてみましたbscan(「」を使用)。

ベストアンサー1

OT1Hは、sshリモートコマンドラインが単一の引数である必要はありません。 OTOHはローカルシェルを介して(sshで)引用符を取得します。そしてsqlite3のリモートシェリングは困難ですが、sqlite3は引数の代わりにstdinでSQLコマンド(;を含む)を受け入れます。これはsshが通常stdin(およびstdoutとstderr)を透過的に処理するので、より簡単です。

 echo "select * from tools where name='bscan';" | ssh [user@]host sqlite3 db

または、シェルがこの文字列(bash、ksh、zsh)をサポートしている場合:

 ssh [user@]host sqlite3 db <<<"select * from tools where name='bscan';"

おすすめ記事