On 4/9/08, Russell V. Lenth <[email protected]> wrote:
> When I try to run Stata in batch mode on Windows...
>
> DOS> wstata /e do testfile.do
>
> ... it runs in the background, returning a new DOS prompt before the job is
> done. That's fine if I'm doing it manually, but I want to run Stata as part
> of a process, and the next step needs Stata to be finished creating its
> output before it starts. I suppose I could have Stata write some new file
> at the very end, but then if there's an error, that file will never get
> written. Ideas?
Depends on the skill level:
1. start /w ........
/w = /wait
2.
DOS>delete file_marker
DOS> wstata /e do testfile.do
// --- testfile.do ---
capture do another.do // capture will ensure we return back to write
the marker
write file_marker
// --- end of testfile.do ---
put your program into another.do
---------------------------------------------------------------------------------------------------------
3. CreateProcessEx(lcExe,lcCommandLine,lcStartDirectory,;
lnShowWindow,llWaitForCompletion,lcStdOutputFilename)
4. ShellExecuteEx(LPSHELLEXECUTEINFO lpExecInfo);
Both 3 and 4 are very similar and converge at one point to the same
thing. Which one to use is a matter of convenience.
---------------------------------------------------------------------------------------------------------
5. if none of the above is ok, I can suggest other variants
Best regards, Sergiy Radyakin
>
> [BTW, the context here is Windows, version Stata/IC, but I need to extend to
> other platforms. e.g., looks like maybe this isn't a problem on Linux --
> just don't put an ampersand?]
>
> Russ
> --
> Russell V. Lenth, Professor
> Department of Statistics
> & Actuarial Science (319)335-0814 FAX (319)335-3017
> The University of Iowa [email protected]
> Iowa City, IA 52242 USA
> http://www.stat.uiowa.edu/~rlenth/
>
> *
> * 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/