os.wait() for Windows

D

Damien Byrne

Hello,

I am new to python. I am using the os module to run a command in a
bashshell. However I need this process to complete before continuing. Is
there a command that will wait for this process to complete? I am using
Windows XP and the os.wait() command only works for UNIX systems, and
therefore doesn't work.

My code is as follows:

import os
FileName = raw_input('Enter the file name: ')
os.system('abaqus job=FileName')
resultsFile = open('FileName.dat','r')

Abaqus will take a few minutes to complete and create the associated results
file. However once I run this code I get the following error ... "IOError:
[Errno 2] No such file or directory: 'FileName.dat'" ... as the file does
not exist yet. Is there any way of waiting for the job to complete before
continuing?

I'd appreciate any help.

_________________________________________________________________
Share folders without harming wildlife!
http://www.communicationevolved.com/en-ie/
 
K

kyosohma

Hello,

I am new to python. I am using the os module to run a command in a
bashshell. However I need this process to complete before continuing. Is
there a command that will wait for this process to complete? I am using
Windows XP and the os.wait() command only works for UNIX systems, and
therefore doesn't work.

My code is as follows:

import os
FileName = raw_input('Enter the file name: ')
os.system('abaqus job=FileName')
resultsFile = open('FileName.dat','r')

Abaqus will take a few minutes to complete and create the associated results
file. However once I run this code I get the following error ... "IOError:
[Errno 2] No such file or directory: 'FileName.dat'" ... as the file does
not exist yet. Is there any way of waiting for the job to complete before
continuing?

I'd appreciate any help.

_________________________________________________________________
Share folders without harming wildlife!http://www.communicationevolved.com/en-ie/


I would recommend subprocess.call(programToRun) or
subprocess.Popen(programToRun).wait()

Mike
 
D

Dennis Lee Bieber

I am new to python. I am using the os module to run a command in a
bashshell. However I need this process to complete before continuing. Is
there a command that will wait for this process to complete? I am using
Windows XP and the os.wait() command only works for UNIX systems, and
therefore doesn't work.
BASH on Windows? You must be running something like Cygwin... (and
even then, does os.system() actually invoke Cygwin's shell?)
My code is as follows:

import os
FileName = raw_input('Enter the file name: ')
os.system('abaqus job=FileName')
resultsFile = open('FileName.dat','r')
Since the documentation for os.system() indicates that it returns
the exit status of the spawned process, that indicates that it should be
waiting -- how else could it return a status for a "still running"
process.
Abaqus will take a few minutes to complete and create the associated results
file. However once I run this code I get the following error ... "IOError:
[Errno 2] No such file or directory: 'FileName.dat'" ... as the file does
not exist yet. Is there any way of waiting for the job to complete before
continuing?
Do you notice any waiting by the os.system() call. If it is /not/,
apparently, waiting for completion I'd suspect that your abaqus command
is creating a detached process of its own, and the command line is
exiting (if you type that command at a shell prompt, do you immediately
get a new shell prompt while the program opens in some other window?).

The only other thing to look at is the subprocess module (which
consolidates a lot of scattered features).
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 

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