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

Hello all! I'm writing Perl script for Win32 environment that should execute Tcl script at the end. My problem is that I have a problem when using filepath that includes spaces:

system ("D:/\RSA Security/\RSA Authentication Manager/\utils/\tcl/\BIN/\tcl-sd.exe $ARGV[1]");

it generates follwing error: 'D:/RSA' is not recognized as an internal or external command. Do you have any idea how to solve this?

Replies are listed 'Best First'.
Re: spaces in filepath on Win32
by b4swine (Pilgrim) on Oct 05, 2007 at 11:02 UTC
    Windows needs quotes around the name with spaces, so windows wants to see:
    "D:\RSA Security\RSA Authentication Manager\utils\tcl\BIN\tcl-sd.exe" +$ARGV[1]
    To do this then, you need to
    system ("\"D:\\RSA Security\\RSA Authentication Manager\\utils\\tcl\\B +IN\\tcl-sd.exe\" $ARGV[1]");
    or nicer looking is
    system '"D:\RSA Security\RSA Authentication Manager\utils\tcl\BIN\tcl- +sd.exe"', $ARGV[1];
    By the way, in the "D:/\RSA.." the /\ sequence is all wrong
Re: spaces in filepath on Win32
by moritz (Cardinal) on Oct 05, 2007 at 10:59 UTC
    You could use the LIST form of system:

    system($path, $ARGV[1]);

    Where $path may contain whitespaces.

Re: spaces in filepath on Win32
by syphilis (Archbishop) on Oct 05, 2007 at 13:50 UTC
    I have a problem when using filepath that includes spaces

    If I was ever to offer a list of advice for Win32 users, then, at the top of the list would be:

    1) Don't ever, under any circumstances, put anything into a directory whose name includes one or more spaces;

    Is that mentioned anywhere on MSDN ? I doubt those Redmond dickheads are capable of offering such basic, common-sense, advice ... correct me if I'm wrong ...

    Sorry ... sounds overly harsh, doesn't it ... I'm not innately anti-Microsoft ... but then I got hold of Vista ('nuff said).

    (Been struggling tonight with 'unresolved reference to _iob' - which is prototyped in stdio.h, fer chrissake !)

    Cheers,
    Rob