LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-01-2011, 01:28 AM   #1
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 423
Blog Entries: 28

Rep: Reputation: 2
syntax problem


Hi, I am trying to output data from sqlite db:
Code:
OUT1="$(sqlite /var/db/blog.db 2>&1 <<SQL
.separator |#|
SELECT * FROM blog WHERE id=\"$id1\" blog LIMIT 1;
bye
SQL
)"

echo "$OUT1"
What should the quotation marks be in red?
It returns an error:
SELECT * FROM blog WHERE id=\"51586430\" blog LIMIT 1; SQL error: unrecognized token: "\" Incomplete SQL: bye

Last edited by ted_chou12; 04-01-2011 at 01:31 AM.
 
Old 04-01-2011, 01:52 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

You marked your thread as solved. Would you mind sharing with the community what the solution was so that others in a similar situation can see if it works for them too? Thanks in advance. Off the Zero Reply List.

Kind regards,

Eric
 
Old 04-01-2011, 01:55 AM   #3
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 423
Blog Entries: 28

Original Poster
Rep: Reputation: 2
Hi! yes, the blackslashes are not required, i dont know why, and it doesnt quite make sense that way, but it works:
Code:
OUT1="$(sqlite /var/db/blog.db 2>&1 <<SQL
.separator |#|
SELECT * FROM blog WHERE id="$id1" blog LIMIT 1;
bye
SQL
)"

echo "$OUT1"
 
Old 04-01-2011, 02:43 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

Thank you for your answer and for marking the thread solved. Enjoy Linux.

Kind regards,

Eric
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Syntax Problem calciferfelix Linux - Newbie 6 12-26-2010 06:49 AM
[SOLVED] Problem with the awk syntax? stmas Linux - Software 5 10-03-2010 03:28 PM
[python] syntax Error : invalid syntax Python_user Programming 2 09-06-2009 01:52 PM
Syntax problem thort Linux - Newbie 9 12-22-2003 04:08 PM
syntax problem jackopa Linux - Software 0 05-08-2002 12:22 AM


All times are GMT -5. The time now is 11:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration