REPOST: Re: os.system commands in CGI on IIS?

James T. Dennis jadestar at idiom.com
Sat Dec 29 12:38:12 EST 2001


Daniel Dittmar <daniel at dittmar.net> wrote:

>> if I execute
>> os.system("copy c:\a.txt c:\b.txt")
>> It does not happen when the cgi page is called from a browser.
>> However if the script is run from the command line, it works fine.

 Try os.system( r"copy c:\a.txt c:\b.txt" )

 ... to make that into a *raw* string (one in which a \ is just
 a \ and not a special character.

> In this specific case, you could use shutil.copy. In general, console 
> applications (like cmd.exe) will not work inside a service or a GUI only 
> program. You might try using the popen2 module, which possibly sets up 
> stdin and stdout just right such that Windows doesn't need the console 
> window. Setting the property 'may interact with desktop' for the IIS 
> service might work as well, but you'll get annoying windows flashing 
> across the screen.

> Daniel

 For this particular example, shutil.copy() is better.  For the
 general case of passing literal strings, esp. MS-DOS compatible 
 filespecs with \'s, use raw strings when you can, mind your 
 escape sequences when you can't.

========= WAS CANCELLED BY =======:
Path: news.sol.net!spool0-nwblwi.newsops.execpc.com!newsfeeds.sol.net!newspump.sol.net!news.maxwell.syr.edu!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r
From: "James T. Dennis" <jadestar at idiom.com>
Newsgroups: comp.lang.python
Subject: cmsg cancel <a0kv24$av1$2 at news.idiom.com>
Control: cancel <a0kv24$av1$2 at news.idiom.com>
Date: Mon, 31 Dec 2001 02:14:10 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.a0kv24$av1$2 at news.idiom.com>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news2.kornet.net 1009774668 27193 211.57.49.2 (31 Dec 2001 04:57:48 GMT)
X-Complaints-To: usenet at news2.kornet.net
NNTP-Posting-Date: Mon, 31 Dec 2001 04:57:48 +0000 (UTC)
X-No-Archive: yes
X-Unac4ncel: yes
X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999)

This message was cancelled from within Mozilla.



More information about the Python-list mailing list