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

Hi, system("D:\\OKL\\Folder ABC\\uncompre temp.gz"); Other than rename the folder name to "Folder_ABC", how can i add on any expression/syntax to make the system() recognise the folder name with spaces ? Thanks
  • Comment on system() doesnt recognise director name with spaces

Replies are listed 'Best First'.
Re: system() doesnt recognise director name with spaces
by BrowserUk (Patriarch) on Sep 16, 2011 at 12:50 UTC

    The shell requires that paths with spaces be quoted, just as when you type them at the keyboard. Use:

    system( q["D:\\OKL\\Folder ABC\\uncompre" temp.gz] );

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: system() doesnt recognise director name with spaces
by Corion (Patriarch) on Sep 16, 2011 at 12:30 UTC

    As you don't show your code, it's hard to tell, but have you checked that your command works as-is within your shell? Most shells want arguments to be specially-quoted if they contain whitespace.

Re: system() doesnt recognise director name with spaces
by Anonymous Monk on Sep 16, 2011 at 12:38 UTC
    The problem stems from your shell interfering with the spaces. Bypass it, thus:
    require IPC::System::Simple; use autodie qw(:all); system('D:/OKL/Folder ABC/uncompre', 'temp.gz');