Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'error:': 0.05; 'subject:skip:s 10': 0.05; 'tom': 0.07; '"my': 0.09; 'cc:addr :python-list': 0.10; 'skip:# 20': 0.13; '"test"': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'specified.': 0.16; 'subject:Problem': 0.16; 'subject:windows': 0.16; 'subprocess': 0.16; 'tjg': 0.16; 'wrote:': 0.17; 'element': 0.17; 'exists': 0.17; "shouldn't": 0.17; 'skip:g 40': 0.17; 'import': 0.21; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'separate': 0.27; '(such': 0.27; 'list:': 0.27; 'running': 0.32; 'path': 0.35; 'received:192.168.0': 0.35; 'skip:g 30': 0.36; 'anything': 0.36; 'subject:with': 0.36; 'subject:: ': 0.38; 'received:192': 0.39; 'skip:" 10': 0.40; 'received:192.168': 0.40; 'from:addr:mail': 0.71; 'received:192.168.0.5': 0.91; 'to:none': 0.93 Date: Sun, 18 Nov 2012 16:19:19 +0000 From: Tim Golden User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 CC: python-list@python.org Subject: Re: Problem with subprocess.call and windows schtasks References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353255571 news.xs4all.nl 6899 [2001:888:2000:d::a6]:54342 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33505 On 18/11/2012 13:48, Tom Borkin wrote: > import subprocess > #subprocess.call(['SchTasks /Create /SC ONCE /TN "My Tasks" /TR "C:/Program > Files/Apache Group/Apache2/htdocs/ccc/run_alert.py" /ST 07:50'], shell=True) > subprocess.call(['SchTasks /Create /SC ONCE /TN "test" /TR "run_alert.py" > /ST 07:50'], shell=True) > With either call, I get this error: > C:\Program Files\Apache Group\Apache2\htdocs\ccc>cron_alert_activity.py > The system cannot find the path specified. Generally, with subprocess call: * Pass each element in the command line as a separate element in the list: ['SchTasks', '/Create', '/SC', 'ONCE', ... &c.] * Don't use shell=True unless you're running a command which is internal to cmd.exe (such as dir, copy, etc.). If you're running anything which exists as its own .exe, you shouldn't be using shell=True. TJG