Solved

Python "os.system" calls using IIS6

Posted on 2009-05-13
2
783 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

776 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