pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Deschamps <pdescham49@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #5978: Running postgress in a shell script fails
Date: Wed, 13 Apr 2011 18:15:31 GMT
Message-ID: <201104131815.p3DIFV3N065457@wwwmaster.postgresql.org> (raw)


The following bug has been logged online:

Bug reference:      5978
Logged by:          Paul Deschamps
Email address:      pdescham49@gmail.com
PostgreSQL version: 8.4.6
Operating system:   Ubuntu 10.4
Description:        Running postgress in a shell script fails
Details: 

When running postgres in a shell using the -c option it looks as though it
parses the contents of the --command as command line arguments. 


---BEGIN SCRIPT---
#!/bin/bash
psql --version
PCOMMAND='psql postgres -c"SELECT tablename FROM PG_TABLES limit 1;"'

echo "PGSQL - Execution from a shell script test"
echo 
echo "Running Command:"${PCOMMAND}

echo "TEST 1 "
OUTPUT1=$(${PCOMMAND})
echo $OUTPUT1
echo
echo "TEST 2"
OUTPUT2=`$PCOMMAND`
echo $OUTPUT2
echo
echo "TEST 3"
OUTPUT3=`exec $PCOMMAND`
echo $OUTPUT3
echo
echo "TEST 4"
$PCOMMAND

echo "TEST 5"
psql postgres -c"SELECT tablename FROM PG_TABLES limit 1;"
---END SCRIPT---

---BEGIN OUTPUT---
[postgres@host03 scripts]$ ./test.sh 
psql (PostgreSQL) 8.4.6
PGSQL - Execution from a shell script test

Running Command:psql postgres -c"SELECT tablename FROM PG_TABLES limit 1;"
TEST 1 
psql: warning: extra command-line argument "FROM" ignored
psql: warning: extra command-line argument "PG_TABLES" ignored
psql: warning: extra command-line argument "limit" ignored
psql: warning: extra command-line argument "1;"" ignored
psql: FATAL:  role "tablename" does not exist


TEST 2
psql: warning: extra command-line argument "FROM" ignored
psql: warning: extra command-line argument "PG_TABLES" ignored
psql: warning: extra command-line argument "limit" ignored
psql: warning: extra command-line argument "1;"" ignored
psql: FATAL:  role "tablename" does not exist


TEST 3
psql: warning: extra command-line argument "FROM" ignored
psql: warning: extra command-line argument "PG_TABLES" ignored
psql: warning: extra command-line argument "limit" ignored
psql: warning: extra command-line argument "1;"" ignored
psql: FATAL:  role "tablename" does not exist


TEST 4
psql: warning: extra command-line argument "FROM" ignored
psql: warning: extra command-line argument "PG_TABLES" ignored
psql: warning: extra command-line argument "limit" ignored
psql: warning: extra command-line argument "1;"" ignored
psql: FATAL:  role "tablename" does not exist
TEST 5
 tablename 
-----------
 pg_type
(1 row)


---END OUTPUT---



view thread (2+ messages)  latest in thread

Message-ID: <201104131815.p3DIFV3N065457@wwwmaster.postgresql.org>
Permalink:  ../201104131815.p3DIFV3N065457@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201104131815.p3DIFV3N065457@wwwmaster.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: pdescham49@gmail.com
  Subject: Re: BUG #5978: Running postgress in a shell script fails
  In-Reply-To: <201104131815.p3DIFV3N065457@wwwmaster.postgresql.org>
  References: <201104131815.p3DIFV3N065457@wwwmaster.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox