[Tutor] how popen works?

Larry Blair lbblair at adaptisinc.com
Wed Jul 21 17:15:50 CEST 2004


I am new to Python and have inherited some difficult code. I am expanding
the functionallity because I can read and figure out what is already there.
I just don't have enough background with Python to know how and why some
things work the way they to.

My script is shutting down an Oracle database, updating snapshots on an EMC
san, and then restarting the Oracle database.

To restart the database I call, via popen, a SQLPlus script, this script
takes about 90 seconds to execute. I thought that Python at the popoen line
would wait until the SQLPlus script was finished and then continue with the
next line of code. I want to do some error trapping AFTER the database us
running. Python however sends the SQLPlus script and then continues
executing the rest of the program.

Am I not understanding what popen does or is there a parameter I need to
send to it to pause until it is finished, or is there a better way of
"shelling" out to the OS and exeuting commands.

Here are examples of what I have tried. Both commands work the same - send
the command to the OS and comes right back and finishes running the script.

We have Win2000 as an OS

1. 

in this I create a cmd window and with the /c tell it to close after sqlplus
is finished

    syncCommand = 'cmd /c sqlplus /nolog @%s' %(local_ccf)
    pipeFile = os.popen("%s" %str(syncCommand)) 


2.  

in this I directly call sqlplus
 
    syncCommand = 'sqlplus /nolog @%s' %(local_ccf)
    pipeFile = os.popen("%s" %str(syncCommand))

Thanks for any insight to this
Larry





__________________________________ 
Confidentiality Notice: This e-mail message, including any attachments, is
for the sole use of the intended recipient(s) and may contain information
that is confidential privileged and/or exempt from disclosure under
applicable law.  Any unauthorized review, use, disclosure or distribution is
prohibited.  If you are not the intended recipient, please contact the
sender by reply e-mail and destroy all copies of the original message.
Thank you.


More information about the Tutor mailing list