bash & postgres

From: Greenhorn <user(dot)postgresql(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: bash & postgres
Date: 2009-03-23 04:03:15
Message-ID: ddcb1c340903222103o72859dem83d39222036b7ef8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Hi,

I'm trying to pass variables on a bash script embedded with psql commands.

cat header.txt

"to1","from1","subject1"
"to2","from2","subject2"
"to3","from3","subject3"
"to4","from4","subject4"

cat b.sh

#!/bin/bash
two="2"

psql -h localhost -U postgres -d mobile -c "create temp table header (

field_1 text not null,
field_2 text not null,
field_3 text not null

);

\\copy header FROM header.txt CSV

SELECT * FROM header limit "$two"; "

When I execute b.sh
================================
ERROR: syntax error at or near "\"
LINE 10: \copy header FROM header.txt CSV
^

How do I use \c (or any other psql commands beginning with a "\") in a
bash script?

Thanks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Harvey, Allan AC 2009-03-23 04:18:13 Re: bash & postgres
Previous Message M L 2009-03-23 02:03:44 Re: The tuple structure of a not-yet-assigned record is indeterminate.

Browse pgsql-sql by date

  From Date Subject
Next Message Harvey, Allan AC 2009-03-23 04:18:13 Re: bash & postgres
Previous Message DM 2009-03-20 22:40:39 pg_restore error - Any Idea?