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

I'm trying to run an .exe from Windows on a command line with spaces in the path and can't quite figure out how it should work.

It looks something like this...

my $stcmdpath = "C:\\Program Files\\Starbase\\StarTeam 5.4"; open(DODIFF, "$stcmdpath\\stcmd.exe diff") or die "Can't find stcmd\n" +; close(DODIFF);
Anyone know how to get this to work. Thanks

jdporter edited: formatted with html

Replies are listed 'Best First'.
Re: path with spaces
by iburrell (Chaplain) on Mar 23, 2004 at 20:16 UTC
    First, you aren't running the command from Perl. You are opening the file called 'C:\Program Files\Starbase\StarTeam 5.4\stcmd.exe diff'. You need to use a piped open:
    open(DODIFF, "$stcmdpath\\stcmd.exe diff |");

    Second, you need to quote the command name for the Windows shell.

    open(DODIFF, "\"$stcmdpath\\stcmd.exe\" diff |");
      Great, thank you! It's working now.