popen2 psql

M

Mage

Hello,

maybe my question is about linux and not about python.

I tried to write a proxy script for "psql" command. I need some query
log. I failed to read from the file object.

I have tested:

a,b = os.popen2('ls')
for s in b.readlines(): print s,

and:

a,b = os.popen2('./pto.py')
for s in b.readlines(): print s,

popen2 works with 'ls' but it doesn't output anything with the './pto.py'.
The 'pto.py' is an existing python script and contains some print.

Likely I have the same problem with popening the python script and the
psql binary. I can simple popen('psql').write(), but I would like to log
everything, so I need stdin and stdout files.

Please help.

Mage
 
K

Klaus Alexander Seistrup

Mage said:
I tried to write a proxy script for "psql" command. I need some
query log. I failed to read from the file object.

The psql command is probably linked against readline; did you look
in the ~/.psql_history file?

Cheers,
 
M

Mage

Klaus said:
Mage wrote:




The psql command is probably linked against readline; did you look
in the ~/.psql_history file?
Thank you. I will check but what about the python scripts? Why can't I
read their *print* output with popen2?

Mage
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top