Saturday, August 28, 2010

Re: Run program with spaces in path

On 28/08/10 18:23, Jakson A. Aquino wrote:
> Hi!
>
> How can a Vim script run a program which has spaces in its path? For
> example, the following "system" command fails with the message
> "'C:\Program' is not recognized as an internal or external command,
> operable program or batch file":
>
> let rcmd = '"C:\Program files\R\R-2.11.1\bin\Rcmd.exe" BATCH "example.R"'
> let rlog = system(rcmd)
> if v:shell_error
> echomsg rlog
> endif
>
> Thanks!
>
> Jakson Aquino
>

On Dos- and Windows-like system you can use the 8.3 form of the
filenames, which will then rid you of the spaces: for instance you could
replace Program Files by PROGRA~1

If you can't use this method, or don't want to, you can use double
quotes on some system and backslash-escaping on others. On Windows you
may need backslash-escaping for internal Vim use and double quotes for
passing to the shell; on Unix-like systems you may need in some cases to
re-escape the escaping backslashes depending on how many levels of
"backslash interpretation" there are.


Best regards,
Tony.
--
Es brilig war. Die schlichte Toven
Wirrten und wimmelten in Waben;
Und aller-mümsige Burggoven
Dir mohmen Räth ausgraben.
-- Lewis Carrol, "Through the Looking Glass"

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: