Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Problem with subprocess.call and windows schtasks (http://www.velocityreviews.com/forums/t954600-re-problem-with-subprocess-call-and-windows-schtasks.html)

Tim Golden 11-18-2012 04:19 PM

Re: Problem with subprocess.call and windows schtasks
 
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


All times are GMT. The time now is 09:12 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.