Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Auto-run program on the hour, every hour


From   "Dan Weitzenfeld" <[email protected]>
To   [email protected]
Subject   Re: st: Auto-run program on the hour, every hour
Date   Wed, 11 Jun 2008 18:15:50 -0700

Thanks Sergiy, that was helpful.  Now I can -run- the file instead of
-do-ing it.

On Wed, Jun 11, 2008 at 5:33 PM, Sergiy Radyakin <[email protected]> wrote:
> Hi,
>
> I am not quite sure that I could follow this thread very carefully,
> but if the Stata is properly associated with the do-files, then one
> can just:
>
> start something.do
>
> without caring where Stata actually is. What -start- will do, is
> actually looking through the registry, finding that .do is associated
> with Stata, looking through the registry again to find where Stata is
> and how to tell it to open a .do file, and finally launching Stata
> (with the word "do"). Here is what help start says:
>
>   "If Command Extensions are enabled, external command invocation
>    through the command line or the START command changes as follows:
>    non-executable files may be invoked through their file association just
>    by typing the name of the file as a command.  (e.g.  WORD.DOC would
>    launch the application associated with the .DOC file extension).
>    See the ASSOC and FTYPE commands for how to create these
>    associations from within a command script."
>
> Which means that you can just have a reference to a do file in your
> batch to launch it:
>
> inventory.do
>
>  (but then you can't pause execution, that's where you need -start- )
>
>
>
> Stata expects it's first parameter to be a command,
> so "wsestata.exe a.do" MUST result in an error:
>
> (199) unrecognized command:  a.do invalid command name
>
> That's why the others suggested having the command -do- in your command line.
>
>
>
> So we are finally coming to the real question: why does your batch
> file actually work ?
>
> What happens in fact is that -start- treats it's first string (quoted)
> parameter as a window title (which for our discussion means it is
> ignored), and you can write with the same success:
>
> start /w "Radyakin" "C:\Documents and
> Settings\Dan\Desktop\STATA/DB_INVENTORY.do"
>
> and it should work too, even though I obviously have nothing to do
> with the configuration of your PC :).
>
> A more obvious test is to write:
> start "Window title"
>
> which is dramatically different from:
> start window title
>
> So the quotes are not just to counteract the spaces in the paths. They
> actually change the meaning of the arguments that -start- parses.
>
> Why would that be important? One day you might be surprised to find
> that if you change the path in your batch file to, say, StataMP, but
> StataSE will still be running as if it was in charge. Or if another
> program reassignes .do-files to itself, your batch may stop working.
>
> A more robust way would be to call the executable with the word do and
> the full filename of the do file:
>
> start /w "Window title does not matter" "C:\Directory
> name\wsestata.exe" do "D:\My Data\inventory.do"
>
> Hope this helps.
>
> Best regards,
>  Sergiy Radyakin
>
>
> On 6/11/08, Dan Weitzenfeld <[email protected]> wrote:
>> Hi All,
>> Thanks much for your help.  I finally got it to work.  Your advice was
>> spot-on; it was Windows that was giving me problems.
>> For posterity, this is how I finally got it to work on my Windows XP computer:
>>
>> 1)  Create .bat file.  (Jeph's no-bat method may work as well, this is
>> just the way I was successful).
>> My .bat file was:
>>
>> Start/w "C:\Program Files\Stata10/wsestata.exe"  "C:\Documents and
>> Settings\Dan\Desktop\STATA/DB_INVENTORY.do"
>>
>> [note that I needed quotes around both filepaths, and did not need the
>> word do in between them]
>> You can test that your .bat file works by double clicking on it - it
>> should open stata and run your do file.
>>
>> 2) Go to Start->Accessories->System Tools -> Scheduled Tasks and
>> double click Add Scheduled Task.
>>
>> 3) Point the wizard toward your .bat file; set up timing etc.
>>
>> 4) Deal with these two key (no pun intended, statisticians) Windows quirks:
>>       -You must have a password set for your account, and you must
>> enter it in during the Scheduled Task wizard setup.  If your account
>> does not have a password, you need to add one for the task to work.
>>       -If, after addressing the password issue, you still get the
>> characteristically cryptic error "0x80070005: Access is denied",  go
>> to http://support.microsoft.com/kb/904423, click the Hotfix link at
>> the top of the page, and download the patch.
>>
>>
>> Thanks again for your help, folks.
>> -Dan
>>
>>
>>
>> On Wed, Jun 11, 2008 at 6:52 AM, Jeph Herrin <[email protected]> wrote:
>> > The .bat file should work, but I think you can skip that
>> > step as long as your command is of the form:
>> >
>> >  C:\Stata10\wstata.exe do mydofile.do
>> >
>> > Note the "do". It's also easier to tinker with the scheduled tasks
>> > if you go to File->New to create the task rather than use the
>> > wizard.
>> >
>> > hth,
>> > Jeph
>> >
>> >
>> > Dan Weitzenfeld wrote:
>> >>
>> >> This is helpful.  My OS is Windows XP.  I'm trying to tinker with the
>> >> properties of the scheduled task  to get it to work... right now all
>> >> it does is pass the name of the do-file to stata in quotes, and Stata
>> >> responds by saying that it's not a valid command.  Does anyone know of
>> >> a way around this?
>> >>
>> >> On Sat, Jun 7, 2008 at 7:01 PM, Jeph Herrin <[email protected]> wrote:
>> >>>
>> >>> I think you want the OS to do this, not Stata. You
>> >>> don't say what your OS is, in Linux see -at-, in
>> >>> XP use the scheduler (Start->Accessories->System Tools
>> >>> -> Scheduled Tasks on my setup, but yours may vary).
>> >>>
>> >>> I don't know about a Mac, though I assume OS X has a
>> >>> command line version of -at-.
>> >>>
>> >>> hope this helps,
>> >>> Jeph
>> >>>
>> >>>
>> >>> Dan Weitzenfeld wrote:
>> >>>>
>> >>>> Hi All,
>> >>>> Is there a way to have a do-file or program run at a given clock-time
>> >>>> every day, automatically?
>> >>>> I can think of a kluge, whereby the program is infinitely looping, and
>> >>>> if c(current_time) fits the desired criteria, the process runs.
>> >>>> I'm wondering if there is a more sane way to achieve this result?
>> >>>> Thanks in advance,
>> >>>> Dan
>> >>>> *
>> >>>> *   For searches and help try:
>> >>>> *   http://www.stata.com/support/faqs/res/findit.html
>> >>>> *   http://www.stata.com/support/statalist/faq
>> >>>> *   http://www.ats.ucla.edu/stat/stata/
>> >>>>
>> >>> *
>> >>> *   For searches and help try:
>> >>> *   http://www.stata.com/support/faqs/res/findit.html
>> >>> *   http://www.stata.com/support/statalist/faq
>> >>> *   http://www.ats.ucla.edu/stat/stata/
>> >>
>> >> *
>> >> *   For searches and help try:
>> >> *   http://www.stata.com/support/faqs/res/findit.html
>> >> *   http://www.stata.com/support/statalist/faq
>> >> *   http://www.ats.ucla.edu/stat/stata/
>> >>
>> > *
>> > *   For searches and help try:
>> > *   http://www.stata.com/support/faqs/res/findit.html
>> > *   http://www.stata.com/support/statalist/faq
>> > *   http://www.ats.ucla.edu/stat/stata/
>> >
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/support/faqs/res/findit.html
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index