0

i am looking to execute the following commands within a shell script:

$ sqlite3 /Users/riceje7/bin/places.sqlite
sqlite > .output places.txt;
sqlite > SELECT url FROM moz_places;
sqlite > .quit;
$ lpr /Users/riceje7/bin/places.txt

however the script stops after the initial sqlite3 command call and only executes the other commands after i manually quit sqlite. does anyone know how i can force the script to execute these commands in this order without having to manually enter them?

1 Answer 1

3

You should be doing..

sqlite3 [OPTIONS] FILENAME [SQL]

so...

sqlite3 /Users/riceje7/bin/places.sqlite  "SELECT url FROM moz_places" > places.txt
lpr /Users/riceje7/bin/places.txt

Or better yet (unless you need to keep places.txt for some reason)...

sqlite3 /Users/riceje7/bin/places.sqlite  "SELECT url FROM moz_places" | lpr
Sign up to request clarification or add additional context in comments.

1 Comment

lpr will be fine reading your data from stdin, so: sqlite3 /Users/riceje7/bin/places.sqlite "SELECT url FROM moz_places" | lpr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.