Using AT on XP to run python script - MARK HAMMOND PLEASE READ

Bengt Richter bokr at oz.net
Thu Jun 6 16:37:02 EDT 2002


On Wed, 5 Jun 2002 16:48:03 -0700, "David LeBlanc" <whisper at oz.net> wrote:

>This is most curious, but I believe the commands _are_ getting executed!
>
>I tried the following (assume time is 16:30) "at 16:32 pythonw
>j:\python22\tools\idle\idle.py" (without the qoutes of course). At the
>appointed time, there was disk activity, but no idle window popped up (idle
>was chosen just to get something to pop up!). However, there _was_ a pythonw
>process running in the task manager! I think there might be a way to attach
>a console or get access to the GUI, but i'm not sure - maybe Mark Hammond
>might have a clue (he being the Python Win guru :) ).
>
>I tried the following:
>#at_test.py
>import sys
>import time
>
>tst = open("testfile.txt", 'a+')
>
>tst.write(time.asctime() + "\n")
>
>tst.close()
>
>put into an 'at' job as: at xx:xx python j:\python22\at_test.py
>
>I expected the output from this to be in j:\python22, but to my surprise, it
>was in c:\winnt\system32 where cmd.exe resides! testfile.txt contained the
>exact time the 'at' job was set to run at too!
>
>I suspect your last example that produced no visible output did in fact work
>:)
>
>In any case, it works - now if one could just get visible output!
>
I's suggest wrapping your python invocation in a .cmd file something like:
--< todoat.cmd >--
c:
cd \pywk
cmd/k D:\python22\python hw.py
------------------

Here hw.py is in c:\pywk
--< hw.py >-------
print 'Hello World from hw.py\n'
------------------

Then you can do this:
==========
[13:19] C:\pywk>at 13:20 /interactive c:\pywk\propt\todoat.cmd
Added a new job with job ID = 1

[13:19] C:\pywk>at
Status ID   Day                     Time          Command Line
-------------------------------------------------------------------------------
        1   Next 6                  13:20         c:\pywk\propt\todoat.cmd

[13:19] C:\pywk>
==========
and have a separate console window pop up (and stay), with this in it:
(Your paths may vary, of course)
==========

C:\WINNT\system32>c:

C:\WINNT\system32>cd \pywk

C:\pywk>cmd/k D:\python22\python hw.py
Hello World from hw.py


C:\pywk>
==========

Some things to note:

The console window popped up, but the path and default directory
have nothing to do with where I did the AT command. The title
of the new console window is C:\WINNT\system32\MSTask.exe.
and the user is the system, with all that may or may not imply ;-)


>David LeBlanc
>Seattle, WA USA
>
>> -----Original Message-----
>> From: python-list-admin at python.org
>> [mailto:python-list-admin at python.org]On Behalf Of Chris Stromberger
>> Sent: Tuesday, June 04, 2002 17:35
>> To: python-list at python.org
>> Subject: Using AT on XP to run python script
>>
>>
>> I'm having trouble getting AT on XP to run a python script for me.
>> Have tried:
>>
>> at xx:xx "c:\python21\python.exe c:\scripts\script.py"
>> at xx:xx "start c:\scripts\script.py"
>> at xx:xx "c:\scripts\script.py"
>>
>> and get "the system cannot find the file specified" for the first two.
>> The last version does nothing apparently--no error indication or
>> anything.
>>
>> I imagine it is related to user accounts and such.  Anyone have any
>> pointers?
Your environment and path are not used by the AT command, so use a .cmd
file that sets things up as needed and then invokes python or pythonw
as needed, depending on whether you want a silent background job or
interaction with whoever happens to be around ;-)
(I'm not sure what happens if no one is logged in. Presumably /interactive
shouldn't work?)

Regards,
Bengt Richter



More information about the Python-list mailing list