Stata shell “command not found” errors

December 14, 2009 at 4:20 am 3 comments

| Gabriel |

I like to use the shell command to pipe commands from Stata to the OS and/or other programs. For instance, graphexportpdf pipes to the Ghostscript command ps2pdf. Unfortunately I pretty often get error messages like this
/bin/bash: ps2pdf: command not found

Sometimes just restarting Stata works, but I’ve found that the only 100% reliable way to get shell to work properly is to execute the script in Stata console instead of You can do this from the Terminal as

exec /Applications/Stata/

Entry filed under: Uncategorized. Tags: , .

Stata2Pajek w vertice colors Diacriticals in Lyx


  • 1. Eric A. Booth  |  December 14, 2009 at 6:12 pm

    I had the same error happen for me. The problem is that, when shelling out from Stata, the system doesn’t know where to look for ‘ps2pdf’. I think my error had something to do with me getting ps2pdf from my TeX installation rather than fink. To resolve it, I first changed the file “init.csh” to include the line “source /sw/bin/init.csh” via:

    edit /sw/bin/init.csh

    and then reinstalled ps2pdf from fink.

    Another option would be to use the command:

    shell /sw/bin/ps2pdf

    (assuming that’s your ps2pdf location) from Stata, it should recognize it then…or you could create an .ado file named ‘ps2pdf’ with some arguments that shelled out to that path if you didn’t want to have to recall the “/sw/bin/” path each time.

    ~ Eric

    • 2. gabrielrossman  |  December 14, 2009 at 6:29 pm

      like you guessed, i mostly use the ps2pdf that comes from my Tex installation (MacTex 2008). however in debugging i also tried installing it through Fink and it still doesn’t work for me, even though “sw” is in my path. i don’t remember exactly, but i believe i also tried targeting the precise path for ps2pdf and didn’t have consistent luck.
      anyway, thanks for the tips. for now stata console works for me but your advice is very good to know if i ever want to get this kind of thing to work in interactive / GUI mode.

  • 3. Eric A. Booth  |  December 14, 2009 at 6:23 pm

    By the way, thanks for creating the graphexportpdf.ado, I use it frequently (and I hadn’t made the connection that you were the author until I was looking at it to write my previous post).

    I had updated the version of your .ado file that I had on my machine to include the “/sw/bin/” path in your -shell- command so that it wouldn’t error out on me & since then – graphexportpdf- seems to work fine now for me.

    ~ Eric

The Culture Geeks

%d bloggers like this: