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';"

관련 정보