The following works great:

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

When I want a specific tool row though:

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

The error is

SQL error: no such column: bscan

I have confirmed the existence of the column name has bscan.

I am assuming my quotes are messed up and I even tried escaping the single quotes around bscan (using ''')


OT1H ssh does not require that the remote command line be a single argument; OTOH getting quotes through both the local shell (to ssh) and the remote shell (to sqlite3) is difficult, but sqlite3 accepts SQL command(s) (with ;) on stdin instead of as an argument which is easier because ssh normally passes through stdin (and stdout and stderr) transparently:

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

or if your shell supports herestring (bash, ksh, zsh):

 ssh [user@]host sqlite3 db <<<"select * from tools where name='bscan';"
  • Definitely glad you showed up thank you for the help. Works like a charm! – mcwilk Nov 16 '17 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.