Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Windows XP - cron or scheduler for Python?

Reply
Thread Tools

Windows XP - cron or scheduler for Python?

 
 
Eric @ Zomething
Guest
Posts: n/a
 
      06-20-2004

I'm trying to have some scripts run periodically on Windows XP and found the "Task Scheduler" did not execute my scripts. My scripts are of the form scriptName.py, and will run just by invoking that name in the Command Prompt.

Has anyone used the Windows Task Scheduler to run .py scripts, and if so is there some intracacy to it?

Is there a more UNIX version of a cron program one can run on Windows?

Has anyone written a simple cron program for Windows in Python, or does anyone see any complication with doing that (which I have not grasped)?

Do I just need to build myself an **IX box?





Eric Pederson
http://www.songzilla.blogspot.com
:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::
e-mail me at:

except, increment the "d" and "o" by one letter
and spell something with a "z"
:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::

 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      06-21-2004
Eric @ Zomething wrote:

> I'm trying to have some scripts run periodically on Windows XP and found the "Task Scheduler" did not execute my scripts. My scripts are of the form scriptName.py, and will run just by invoking that name in the Command Prompt.
>
> Has anyone used the Windows Task Scheduler to run .py scripts, and if so is there some intracacy to it?


I had not tried it, so I just did. My first attempt failed. As it
turned out, it was because I ignore the password field, assuming
it would be able to run anyway while I was logged in. The "status"
field in the Task Scheduler window showed the reason... once I
fixed that, it did work, either as "c:/tick.py" (make sure you
include the right path here or in the "start in this folder" field)
or as "c:/a/python23/python.exe c:/tick.py".

If it's not working, double-check the status field to see why it
didn't work...

-Peter
 
Reply With Quote
 
 
 
 
Larry Bates
Guest
Posts: n/a
 
      06-21-2004
I run python programs ALL the time on Windows XP
using the scheduler. Two things you must
remember when doing this:

1) Your program runs in a "different" environment
than your foreground application. It DOES NOT
inherit drive mappings, environment variables,
paths, etc. so you must fully qualify everything.

2) Always call Python and have it run the application.
Don't just try to run progname.py.

HTH,

Larry Bates
Syscon, Inc.

"Eric @ Zomething" <> wrote in message
news:mailman.78.1087794803.454.python-...

I'm trying to have some scripts run periodically on Windows XP and found the
"Task Scheduler" did not execute my scripts. My scripts are of the form
scriptName.py, and will run just by invoking that name in the Command
Prompt.

Has anyone used the Windows Task Scheduler to run .py scripts, and if so is
there some intracacy to it?

Is there a more UNIX version of a cron program one can run on Windows?

Has anyone written a simple cron program for Windows in Python, or does
anyone see any complication with doing that (which I have not grasped)?

Do I just need to build myself an **IX box?





Eric Pederson
http://www.songzilla.blogspot.com
:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::
e-mail me at:

except, increment the "d" and "o" by one letter
and spell something with a "z"
:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::


 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      06-21-2004
Larry Bates wrote:

> 2) Always call Python and have it run the application.
> Don't just try to run progname.py.


This actually works, though, at least on my system. It
might be because I inserted .py in the PATHEXT env var
globally, though I thought it was just because running
a .py is possible simply by clicking on it in Explorer
(ie. the File Association does the job).

-Peter
 
Reply With Quote
 
Ivan Voras
Guest
Posts: n/a
 
      06-21-2004
Peter Hansen wrote:
> Larry Bates wrote:
>
>> 2) Always call Python and have it run the application.
>> Don't just try to run progname.py.

>
>
> This actually works, though, at least on my system. It
> might be because I inserted .py in the PATHEXT env var
> globally, though I thought it was just because running
> a .py is possible simply by clicking on it in Explorer
> (ie. the File Association does the job).


No, putting .py in PATHEXT is necessary. That way, you can run python
programs from the command line (cmd) using just "scriptname", without the
extension! (it performs just like .bat, .exe and similar files)
 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      06-21-2004
Ivan Voras wrote:

> Peter Hansen wrote:
>
>> Larry Bates wrote:
>>
>>> 2) Always call Python and have it run the application.
>>> Don't just try to run progname.py.

>>
>> This actually works, though, at least on my system. It
>> might be because I inserted .py in the PATHEXT env var
>> globally, though I thought it was just because running
>> a .py is possible simply by clicking on it in Explorer
>> (ie. the File Association does the job).

>
> No, putting .py in PATHEXT is necessary. That way, you can run python
> programs from the command line (cmd) using just "scriptname", without
> the extension! (it performs just like .bat, .exe and similar files)


Are you sure? I just tried removing .py from my PATHEXT and
not only did it still work from Explorer, it even worked from
the command line!

Then I tried redirecting the File Assocation under File Types
to point to notepad instead of python. Now typing "xxx.py"
at the command line or clicking on the xxx.py file in
Explorer both launch Notepad to edit the file.

I'm not sure what PATHEXT is really needed for, but executing
..py files on the command line in Windows XP does not seem to
be one of them...

-Peter
 
Reply With Quote
 
Thorsten Kampe
Guest
Posts: n/a
 
      06-21-2004
* Peter Hansen (2004-06-21 19:35 +0200)
> Ivan Voras wrote:
>> Peter Hansen wrote:
>>> Larry Bates wrote:
>>>> 2) Always call Python and have it run the application.
>>>> Don't just try to run progname.py.
>>>
>>> This actually works, though, at least on my system. It
>>> might be because I inserted .py in the PATHEXT env var
>>> globally, though I thought it was just because running
>>> a .py is possible simply by clicking on it in Explorer
>>> (ie. the File Association does the job).

>>
>> No, putting .py in PATHEXT is necessary. That way, you can run python
>> programs from the command line (cmd) using just "scriptname", without
>> the extension! (it performs just like .bat, .exe and similar files)

>
> Are you sure? I just tried removing .py from my PATHEXT and
> not only did it still work from Explorer, it even worked from
> the command line!
>
> Then I tried redirecting the File Assocation under File Types
> to point to notepad instead of python. Now typing "xxx.py"
> at the command line or clicking on the xxx.py file in
> Explorer both launch Notepad to edit the file.
>
> I'm not sure what PATHEXT is really needed for, but executing
> .py files on the command line in Windows XP does not seem to
> be one of them...


"PATHEXT" enables you to run files in the path with these extensions
without extension (for example "winword" instead of "winword.exe").
The cmd shell actually performs an "open" action. For executables
"opening" is running them. For documents it's starting the associated
application and opening the document in it. For .py both things are
reasonable.

Thorsten
 
Reply With Quote
 
Jay Donnell
Guest
Posts: n/a
 
      06-21-2004
> 2) Always call Python and have it run the application.
> Don't just try to run progname.py.


How would one do this. I'm a unix geek having the same problems as the
op, but I'm on windows 2000. The status simply says "couldn't start".
Any other ideas would be appreciated as well.
 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      06-22-2004
Jay Donnell wrote:

>>2) Always call Python and have it run the application.
>>Don't just try to run progname.py.

>
> How would one do this. I'm a unix geek having the same problems as the
> op, but I'm on windows 2000. The status simply says "couldn't start".
> Any other ideas would be appreciated as well.


For starters, try full absolute paths for both parts. On
my machine, for example, this is pretty much guaranteed
to run:

c:\a\python23\python.exe c:\tick.py

This was just the following script, which you might want
to try as a test, but it works only if the pywin32 stuff
(formerly known as win32all) is installed:

import win32ui
win32ui.MessageBox('it works!', 'Tick', 0)

If even that doesn't work (after correcting the paths
and module name for your own system), open a command prompt
(Start->Run then type "cmd" and hit enter) and type
exactly the same thing there. If *that* doesn't work,
you don't even have Python installed properly...

-Peter
 
Reply With Quote
 
Roger Upole
Guest
Posts: n/a
 
      06-22-2004
You can retrieve the startup error code using the Pywin32 package.
(requires build 201)

import pythoncom, win32api
from win32com.taskscheduler import taskscheduler
ts=pythoncom.CoCreateInstance(taskscheduler.CLSID_ CTaskScheduler,None,

pythoncom.CLSCTX_INPROC_SERVER,taskscheduler.IID_I TaskScheduler)
task=ts.Activate('your task name')
exit_code,startup_error_code=task.GetExitCode()
print win32api.FormatMessage(startup_error_code)
hth
Roger


"Jay Donnell" <> wrote in message
news: om...
> > 2) Always call Python and have it run the application.
> > Don't just try to run progname.py.

>
> How would one do this. I'm a unix geek having the same problems as the
> op, but I'm on windows 2000. The status simply says "couldn't start".
> Any other ideas would be appreciated as well.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dotnet scheduler like the Windows "Schedued Tasks" scheduler? Codemonkey ASP .Net 8 06-10-2011 10:53 AM
RE: Windows XP - cron or scheduler for Python? Tim Golden Python 4 12-23-2004 07:15 PM
Windows Task Scheduler David Computer Support 0 10-07-2003 02:06 AM
Windows 2000, scheduler and java Christina Robertson Java 2 09-12-2003 12:22 PM
windows xp home edition task scheduler problems rtdos \(status@rtdos.info\) Computer Support 0 07-15-2003 04:07 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57