Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I need help with one question. I would like to run an external executable written in fortran which provides one of the inputs inside a python code. Is it possible to run that exe inside python script?

Thanks, Ibe

share|improve this question
2  
I suggest migrating this question to SO if it doesn't get a quick answer here, because it really is seeking pure Python expertise. (You can migrate it by following the "flag" link to contact a moderator.) –  whuber Dec 22 '11 at 15:33
    
I think subprocess is the way to do this nowadays. –  Paul Hiemstra Dec 22 '11 at 21:54
2  
In addition, googling for "python run extrnal executable" got me the answer quite quickly. No offense, but have you tried this? –  Paul Hiemstra Dec 22 '11 at 21:59
    
I wasn't aware subprocess before. –  Ibe Dec 26 '11 at 3:46
add comment

2 Answers

up vote 7 down vote accepted

Use the subprocess module.

E.g:

proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
stdout,stderr=proc.communicate()
exit_code=proc.wait()
print exit_code,stdout.read(),stderr.read()
share|improve this answer
add comment

Look into os.system and related Python stuff. SO is a good place to ask related questions.

share|improve this answer
    
Sorry for missing one important point that i have to run it in the arcgis environment. –  Ibe Dec 22 '11 at 16:03
2  
I'm not sure how that matters. If you're using a Python script, you should have access to any of the Python libraries. –  Anthony -GISCOE- Dec 22 '11 at 16:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.