Solved

Python "os.system" calls using IIS6

Posted on 2009-05-13
2
777 Views
Last Modified: 2013-12-25
I am executing a python script on a web server running Windows 2003, IIS6, and FastCGI.  I have have my web extensions all set up, and most python scripts run just fine from the browser.  It's only when I try to make "os.system" calls that things fail.

I have a script here that runs fine from command line and generates textfile.  When run from a web browser however, this does not work:
---------------------
import os
os.system('touch output.txt')
os.system('echo 1 >> output.txt')
---------------------

I have seen several others ask this same question all over the web since 2001, but no one ever seems to get a real answer.  Does anyone know why this does not work in IIS?  More importantly, does anyone know how to make this work in IIS?

Thanks.
0
Comment
Question by:m_mccabe
2 Comments
 
LVL 22

Accepted Solution

by:
cj_1969 earned 500 total points
ID: 24384004
Chances are if you are running IIS 6 then the code is running using the Network Service account.  My guess is that this account does not have permission to execute the call you are making.

Try creating a new application pool and change the logon ID of the application pool to either Local System or create a local/domain account and grant it appropriate permissions and see if this fixes the problem.
0
 
LVL 3

Author Closing Comment

by:m_mccabe
ID: 31581151
Thanks a ton, cj_1969!  I tried your solution and it worked.  During this process, it also got me thinking about permissions, and in the end I only needed to grant the IUSR_%computername% account access to python.exe and cmd.exe.

Thanks so much for getting me on the right track.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now