David
David

Reputation: 961

running sqlite3 script inside bash

I am trying to run multiple commands from a bash file of sqlite3 on ubuntu 15.10. The code is to pull the passwords from the user's google chrome and email it to them. I have everything but the sqlite3 part down. I'm trying to make this as simple and as easy to use for them as possible. I don't know sqlite3 and it's kicking my tail. How would I produce a bash file using this sqlite3 code?

sqlite3 'Login Data'
.mode csv
.headers on
.separator ","
.output UsersPW.csv
select * from logins;
.exit

Upvotes: 3

Views: 1637

Answers (1)

David
David

Reputation: 961

The answer was simple enough. Inside batch you can echo large data with << EOF structure.

sqlite3 'Login Data' << EOF
.mode csv 
.headers on 
.separator "," 
.output UserPW.csv 
select * from logins; 
.exit
EOF

This created the results I was needing.

Upvotes: 2

Related Questions