On Jan 28, 2006, at 4:12 PM, Rich Shepard wrote:

Please keep replies on the mailing list.

<snip>

Again, you can't use redirection via the psql prompt. But you can do it
via your shell command line:

$ psql -c "\dt" > xrms.tables

  Well, that doesn't seem to be working here, either:

[EMAIL PROTECTED] ~]$ psql -c contacts "\dt" > xrms.tables
psql: FATAL:  database "\dt" does not exist

[EMAIL PROTECTED] ~]$ psql "-c contacts \dt" > xrms.tables
psql: FATAL:  database "rshepard" does not exist

[EMAIL PROTECTED] ~]$ psql -c contacts
psql: FATAL:  database "rshepard" does not exist

That's because you've used the wrong syntax.

$ psql contacts -c "\dt" > xrms.tables

This is why I suggested you read the psql man page.

Alternatively, you can use psql's "\o [FILE]" command to redirect query results to a file:
  This creates the file, but it's empty.

I'm curious what's gone wrong here. Nothing seems to be working as it
should.

Likely, the output is buffered. Did you try quitting psql (via \q) before checking the contents of the file.

You should also read the psql man page and the output of psql's "\h" command.

I've done both and tried various combinations of syntax. For example:

[EMAIL PROTECTED] ~]$ psql -d contacts -c pg_dump  -o xrms.tables
ERROR:  syntax error at or near "pg_dump" at character 1
LINE 1: pg_dump

Dude, "pg_dump" is not a psql command, nor is it a SQL command. It's a command-line program. You run it from your shell:

$ pg_dump --schema-only pg_dump > xrms-schema.dmp

  All I get are error messages.

You continually do the wrong things.  Read the man pages.  Seriously.

eric

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to