os.system behavior when calling SQLPlus with spooling

S

steve551979

I'm trying to execute SQLPlus in python (on Redhat linux).

when calling sqlplus, i'm referencing an sql file which spools results
to a file, for e.g.:

spool "/tmp/qctemp2.out";
SELECT %s
FROM bug
WHERE BG_BUG_ID = %s;
spool off;
exit;


I'm noticing that when using:

os.system("sqlplus -S -L %s @/tmp/qctemp3.sql" % qc_login)

I'm able to execute fine, however, when I use:

f = popen4(("sqlplus -S -L %s @/tmp/qctemp3.sql" % qc_login)
print f.read()

I get problems where occasionally, sqlplus is run, but has problems
spooling results to a file, and python hangs on the print f.read()
statement.

I would prefer not to use os.system() since I want to analyze the
results. Can anyone suggest how I should go about executing sqlplus
in this case?

Thanks for your help,
Steve

(note: please do not reply to my email address, only reply to this
group)
 
M

Martin v. Löwis

I would prefer not to use os.system() since I want to analyze the
results. Can anyone suggest how I should go about executing sqlplus
in this case?

You need to find out why it hangs. Perhaps sqlplus tries to read from
its stdin, asking the user for input, yet your script doesn't provide
any?

You can use "strace -p <id of sqlplus>" to find out what it's doing
when it hangs.

Regards,
Martin
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top