How to capture an interactive psql session in a log file?
What I'm trying to do doesn't seem like it should be that difficult or
unusual, but I can't seem to find the right combination of commands to make
it happen. I want to have a log file that captures everything from an
interactive psql session. Running 8.3.7 with bash shell on Linux.
If I use \o <file> or \o |tee <file, it doesn't capture my entered commands,
or any error text.
I can use some fancy bash to capture stderr in the file too, and then error
text goes there, but no matter what, neither the commands I enter nor the
psql prompt will be captured in the log file.
This is even when using -a, or \set ECHO all. It's as if my entered
commands neither go to stdout or stderr.
Has anyone solved this issue before?
Thanks in advance
Gordon
--
View this message in context: http://www.nabble.com/How-to-capture-an-interactive-psql-session-in-a-log-file--tp22862412p22862412.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On Thu, Apr 02, 2009 at 10:55:10PM -0700, Gordon Shannon wrote:
Has anyone solved this issue before?
have you seen program "script"?
usage:
just run script
you will get shell. now run your command you want to capture everything
from - it will work as usual.
after you finish - exit the "script-shell", and check the generated
typescript file
Best regards,
depesz
--
Linkedin: http://www.linkedin.com/in/depesz / blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007
That does the trick, awesome!
I do think it would be great if psql had a "stderr" capture in addition to
stdout.
Thanks
hubert depesz lubaczewski-2 wrote:
On Thu, Apr 02, 2009 at 10:55:10PM -0700, Gordon Shannon wrote:
Has anyone solved this issue before?
have you seen program "script"?
usage:
just run script
you will get shell. now run your command you want to capture everything
from - it will work as usual.
after you finish - exit the "script-shell", and check the generated
typescript fileBest regards,
depesz
--
Linkedin: http://www.linkedin.com/in/depesz / blog:
http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl /
gg:6749007--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
--
View this message in context: http://www.nabble.com/How-to-capture-an-interactive-psql-session-in-a-log-file--tp22862412p22862519.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On Thu, Apr 2, 2009 at 11:55 PM, Gordon Shannon <gordo169@gmail.com> wrote:
What I'm trying to do doesn't seem like it should be that difficult or
unusual, but I can't seem to find the right combination of commands to make
it happen. I want to have a log file that captures everything from an
interactive psql session. Running 8.3.7 with bash shell on Linux.
Look up the screen command. It's pretty standard on most unixes.
In response to Scott Marlowe :
On Thu, Apr 2, 2009 at 11:55 PM, Gordon Shannon <gordo169@gmail.com> wrote:
What I'm trying to do doesn't seem like it should be that difficult or
unusual, but I can't seem to find the right combination of commands to make
it happen. �I want to have a log file that captures everything from an
interactive psql session. �Running 8.3.7 with bash shell on Linux.Look up the screen command. It's pretty standard on most unixes.
s/screen/script/
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
On Fri, Apr 3, 2009 at 1:20 AM, A. Kretschmer
<andreas.kretschmer@schollglas.com> wrote:
In response to Scott Marlowe :
On Thu, Apr 2, 2009 at 11:55 PM, Gordon Shannon <gordo169@gmail.com> wrote:
What I'm trying to do doesn't seem like it should be that difficult or
unusual, but I can't seem to find the right combination of commands to make
it happen. I want to have a log file that captures everything from an
interactive psql session. Running 8.3.7 with bash shell on Linux.Look up the screen command. It's pretty standard on most unixes.
s/screen/script/
Thanks. I was thinking script, honest. I need to get to sleep.
On Fri, Apr 03, 2009, Scott Marlowe wrote:
On Fri, Apr 3, 2009 at 1:20 AM, A. Kretschmer
<andreas.kretschmer@schollglas.com> wrote:In response to Scott Marlowe :
On Thu, Apr 2, 2009 at 11:55 PM, Gordon Shannon <gordo169@gmail.com> wrote:
What I'm trying to do doesn't seem like it should be that difficult or
unusual, but I can't seem to find the right combination of commands to make
it happen. I want to have a log file that captures everything from an
interactive psql session. Running 8.3.7 with bash shell on Linux.Look up the screen command. It's pretty standard on most unixes.
s/screen/script/
Thanks. I was thinking script, honest. I need to get to sleep.
Though you can log with screen in the same fashion as script with
'C-a H'. :)
--
Mahlon E. Smith
http://www.martini.nu/contact.html
On Apr 2, 2009, at 11:07 PM, Gordon Shannon wrote:
That does the trick, awesome!
I do think it would be great if psql had a "stderr" capture in
addition to
stdout.
While the recommendations to use script are perfect for the use case
of capturing everything, including input, I think it's worth
mentioning that there was some discussion not too long ago to give
psql better IO redirection capabilities. The suggestion I like was
something along the lines of
pagila# \o > stdout.txt 2> stderr.txt
as the meaning of that should be immediately obvious to most *nix
users and would also allow
pagila# \o > allout.txt 2>&
and this would default to stdout for backwards compatibility (and
simplicity)
pagila# \o stdout.txt
Erik Jones, Database Administrator
Engine Yard
Support, Scalability, Reliability
866.518.9273 x 260
Location: US/Pacific
IRC: mage2k