os.system behavior when calling SQLPlus with spooling

Discussion in 'Python' started by steve551979@hotmail.com, Jan 24, 2008.

  1. Guest

    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)
     
    , Jan 24, 2008
    #1
    1. Advertising

  2. > 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
     
    Martin v. Löwis, Jan 24, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gianni

    Sqlplus - S stops ...sigh !

    Gianni, Jun 17, 2004, in forum: Perl
    Replies:
    4
    Views:
    6,415
    Karel Kubat
    Jul 1, 2004
  2. Gianni

    Sqlplus -S interrupt !!!!

    Gianni, Jun 17, 2004, in forum: Perl
    Replies:
    0
    Views:
    2,948
    Gianni
    Jun 17, 2004
  3. Replies:
    0
    Views:
    349
  4. Daniel Berger

    Driving Oracle sqlplus with open3

    Daniel Berger, Jul 26, 2006, in forum: Ruby
    Replies:
    11
    Views:
    286
    Pra Bhandar
    Mar 3, 2009
  5. The alMIGHTY N

    SQLPlus with Perl

    The alMIGHTY N, Nov 2, 2006, in forum: Perl Misc
    Replies:
    7
    Views:
    1,636
    Peter Scott
    Nov 3, 2006
Loading...

Share This Page