Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

closed as off-topic by PolyGeo Nov 25 '15 at 11:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general Information Technology, with no clear GIS component, are off-topic here, but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software) and Database Administrators (relational databases)" – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

3  
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
1  
I think subprocess is the way to do this nowadays. – Paul Hiemstra Dec 22 '11 at 21:54
3  
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
up vote 8 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

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
3  
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

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