Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Novel feature of -shell- under Windows


From   Roger Newson <[email protected]>
To   [email protected]
Subject   Re: st: RE: Novel feature of -shell- under Windows
Date   Tue, 13 Jul 2004 10:23:00 +0100

Thanks to James for his prompt and very helpful reply, and in advance to StataCorp for fixing this problem in the next executable update. I might have guessed that this would be Microsoft's fault. Now I am ever so curious as to how exactly -cmd.exe- parses an input string containing multiple " characters, in order to produce this result. However, this is really a Microsoft query, not a Stata query.

Best wishes

Roger

At 23:36 12/07/2004, James Hassell wrote:


Roger Newson wrote:

>I think I have discovered an unwanted new feature of the -shell- command,
>at least in the 01 July 2004 version of Stata 8.2 under Windows 2000. It
>appears not to work when both the DOS command path and the filename are
>enclosed in quotes.
>
>This feature of the -shell- command has partially disabled my -stcmd-
>package, which is downloadable from SSC and also shipped with official
>StatTransfer 7, but which will no longer work with filenames in quotes,
>which used to cause no problems. I personally would never define a filename
>containing spaces (and therefore necessitating quotes), but some of my
>SPSS-using collaborators do this with the .sav files which they send me.
>(As a quick and dirty fix, I suppose I always could rename these .sav
>files, substituting underscores for blanks.)

I was able to reproduce the behavior that Roger described and eventually
track down the problem. This problem occurs when the command issued to
-shell- must be enclosed in quotation marks. In some circumstances this
is unavoidable since the command issued to -shell- is located in a folder
such as "Program Files".

Under Windows OS versions such as XP and 2000, commands passed to -cmd.exe-
that are quoted, require the entire command and argument list to be quoted.
(Underneath Stata makes a call to -cmd.exe-)

Here is a simple experiment that exploits the problem. From the Windows
-Start Menu- >> -Run- type :

        cmd.exe /c "notepad" "junk.txt"

You should find that this fails, but typing :

        cmd.exe /c ""notepad" "junk.txt""

will work. (notice the extra set of quotes)

For a temporary work around, this technique can be used with the -shell-
command.

Example:

        . shell ""notepad" "junk 1.txt""


The work around is really only suitable for interactive use, because
the fix, which will be made available in the next executable update,
would have the effect of breaking the work around. That is, Windows
does not like :

        -cmd.exe /c """notepad" "junk.txt"""-



-- James
[email protected]

*
*   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/

--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
  or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]
Website: http://www.kcl-phs.org.uk/rogernewson

Opinions expressed are those of the author, not the institution.

*
*   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