Announcement

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

  • Shell

    Hello,

    Complete novice shell user, please take mercy on me...

    I am trying to run an executable via Stata's "shell" command. In case it matters, I'm running curl (http://www.confusedbycode.com/curl/) to download data via and API.

    I was concerned there was a PATH issue, so specified the location of curl.exe explicitly.

    I've tried three approaches:

    1. No Stata: Success
    a. Open command line directly
    b. Manually copy into command window:
    Code:
     "C:\Program Files\cURL\bin\curl.exe" blah blah
    This is successful.

    2. Partial Stata: Success
    a. In Stata run:
    Code:
     shell
    b. Manually copy into shell window:
    Code:
     "C:\Program Files\cURL\bin\curl.exe" blah blah
    This is successful.

    3. Fully in Stata: Failure
    a. In Stata run:
    Code:
     shell "C:\Program Files\cURL\bin\curl.exe" blah blah
    This fails. It doesn't bring an error in the shell, but generates meaningless data rather than the data I want to download.


    While I'm certainly in over my head, based on my understanding of Stata's shell command, I believe (2) and (3) are functionally exactly equivalent. Any idea what is different, and/or what is causing (3) to fail?

    Thanks very much!

  • #2
    Dear William,
    In my own syntax, I have to use double quotes, like:
    Code:
    global shell ""C:\Program Files\Ghostscript\bin\gswin64c.exe""
    Possibly, you should code it like:
    Code:
     
     shell ""C:\Program Files\cURL\bin\curl.exe" blah blah"
    Give it a try.
    http://publicationslist.org/eric.melse

    Comment


    • #3
      Yes, this solved it! I had some weird characters that were apparently confusing Stata, but the double quotes fixed it.

      Thanks much!

      Comment

      Working...
      X