matze77 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all!
How could i mask this? Doublequotes are not working ...

system("if not exist "%ALLUSERSPROFILE%\\desktop\\gast_2005.exe" copy \\\\server\\groups\\support\\gast_2005.exe "%ALLUSERSPROFILE%\\desktop"")

echo %allusersprofile% C:\Dokumente und Einstellungen\All Users
The spaces are the problem ...
Thanks
MH

Replies are listed 'Best First'.
Re: How to quote system () and a path with spaces?
by ikegami (Patriarch) on Nov 10, 2009 at 07:13 UTC
    Put double-quotes around it. And how do you place double-quotes in a double-quoted string? Escape them with backslahes.


      Note to myself:
      Reread documentation ...

      Thanks @ all
      MH
Re: How to quote system () and a path with spaces?
by cdarke (Prior) on Nov 10, 2009 at 09:06 UTC
    or, use single quotes. You are not doing any interpolation (variable and special character substitution) within the system command, so there is no need to use double-quotes around the outside. Even if you were you could use qq:
    system(qq(if not exist "%ALLUSERSPROFILE%\\desktop\\gast_2005.exe" cop +y \\\\server\\groups\\support\\gast_2005.exe "%ALLUSERSPROFILE%\\desk +top"))
Re: How to quote system () and a path with spaces?
by rovf (Priest) on Nov 10, 2009 at 09:41 UTC

    system(qq(if not exists "....." copy ...));
    Although one might ask why you want to shell out at all, if you can do the same as easily within Perl...

    -- 
    Ronald Fischer <ynnor@mm.st>