Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shell commands in batch mode


    Dear Statalist, Using shell commands in batch mode provide the following error: "request ignored because of batch mode" Any way around it? I use Stata 14 on a Windows 10 machine. *This problem was raised in 2010, and 2013 without response.

  • #2
    I encountered the same problem, using Stata 14 on Windows 7.

    I find this extremely irritating, particularly because, at least back in 2010, Stata had no problem running shell commands in batch mode on OS X. Stata seems to say, "I could do this, but because you use Windows, I would prefer not to." Is there any reason at all why it cannot?

    Stata's recalcitrance in this particular is NOT replicated in R, which makes me wonder why I use Stata at all. It would take me about six hours to translate the relevant program from Stata into R, which is six hours more than I would prefer, but perhaps, in the long run, spending six hours to translate a program will be less costly than letting my organization's data analysis infrastructure snowball around software that occasionally chooses not to work.

    Comment


    • #3
      Is there any update on this? I use shell commands to send updates to my cellphone (see sendtoslack) and I thought it'd be a great pairing with batch mode, because it means you stay updated on what's going on. Instead, it turns out batch mode skips all shell commands, meaning I either have to use convoluted logging/file writing procedures or stay in the dark on the progress of my files.

      Comment


      • #4
        Long shot but...any updates? Would make my life much easier if could run shell in batch mode...

        Comment


        • #5
          Stata 15 on Windows also ignores shell command while batch mode.
          Instead of using /e or /b options, to add exit , clear STATA to the end of the do-file might be an alternative.

          Run following code within cmd.exe:
          Code:
          "path\to\StataMP-64.exe" do "path\to\my.do"
          If my.do ends with following line, Stata will quit after executing the do-file:
          Code:
          exit , clear STATA
          Note that option STATA is case-sensitive.
          (If you are running cmd as Administrator, taskkill command could work without modifying your do-file).

          Also, for those who want to run Stata within WSL:
          Its quite weird but WSL path does not work at all in case of Stata. You should run Stata via cmd.exe within WSL. You might want to write a wrapper script named stata in ~/bin directory as following:
          Code:
          #!/bin/bash
          cmd.exe /c "path\to\StataMP-64.exe" "$@"
          Then following code will do the same thing as above.
          Code:
          stata do "path\to\my.do"
          Note that "path\to\StataMP-64.exe" and "path\to\my.do" must be Windows path(C:\...) not WSL path(/mnt/c/...).
          Last edited by JeongHoon Min; 01 Jan 2020, 17:41.

          Comment


          • #6
            In case anyone should be discouraged from attempting to use shell commands in a do-file that is run from a batch file, I have been able to make this work using Stata 18 with Windows 10 using the standard way of running Stata in batch file:

            Code:
            cd \test\subdir
            "\path\Stata18\StataMP-64,exe" /e do testprog.do
            The only point to note is that I use the !win_cmd syntax rather than the shell command. This works with curl, but I have not tested with other Windows programs.

            Comment

            Working...
            X