John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

This used to work! I updated the paths to reflect my current situation, and Perl is a newer version (ActiveState build 628).

Here are the relevent lines:

my $VSS= '"D:\Program Files\\Microsoft Visual Studio\\Common\\VSS\\win +32\\ss.exe"'; system $VSS ("ss", "checkout -I-");
I get an error that CMD.EXE was not found.

According to the documentation, this should run ss.exe directly and not involve the command shell. And even then, I don't know why it can't find it.

Any clues?

—John

Replies are listed 'Best First'.
(tye)Re: 'system' not working!
by tye (Sage) on Oct 25, 2001 at 00:26 UTC

    The quotes to "escape" spaces in file names are only required when the file name is part of a command line that is going to be split on spaces. The indirect object to system is not part of the command line so drop the quotes. That makes it work for me.

            - tye (but my friends call me "Tye")
      That makes it break differently for me. I took out the quotes, and get
      Unrecognized command: Files\Microsoft
      which is why I added the quotes in the first place.

      It also shows that I get a different error for a genuine "not found", as opposed to a not-found making it look for CMD as a fallback... hmm, maybe it's a read herring, and the error is from VS.exe itself, not from Perl! I'll explore that.

      (Meanwhile, why does it work for you without the quotes?)

      —John

        Okay, I even went out of my way and renamed some things so that I had spaces in my path but that didn't change my results. This type of stuff has changed between versions of Perl so perhaps that explains our different results. I was doing this testing using v5.6.0 ActivePerl build 616.

        I suspect that Perl's 'if CreateProcess() fails, then just retry with CreateProcess("cmd.exe","/c ...",...)' logic is masking the real error here. I'd think that using an indirect object with system would disable that logic, but I haven't checked that.

        In any case, you can always do:

        use Win32; $vss= Win32::GetShortPathName( "D:\\Program Files\\" . "Microsoft Visual Studio\\Common\\VSS\\win32\\ss.exe");
        and I'm pretty sure that will fix errors due to spaces in file names.

        You also might want to try Win32::Process to see if you can reproduce why Perl thinks CreateProcess() is failing.

                - tye (but my friends call me "Tye")
Re: 'system' not working!
by MZSanford (Curate) on Oct 25, 2001 at 13:25 UTC
    I have had similar problems with paths that contain spaces, and i usually end up using the DOS names for the directory, just to be sure, maybe :
    $VSS = 'D:\progra~1\micros~3\common\VSS\win32\ss.exe'; #... system($VSS,'ss','checkout -I-');

    I also moved the parens on system, because i thought it made cleared the precedence you wanted, but i don't suspect that is a cause for error. If you still suspect it, you could use fork() and exec() yourself.
    i had a memory leak once, and it ruined my favorite shirt.
      Good idea re the spaces. I'll try that.

      Changing the parens changed the meaning, though. Take out the 'ss' if you do that.

Re: 'system' not working!
by VSarkiss (Monsignor) on Oct 24, 2001 at 23:54 UTC

    Don't know if this is just a copy-and-paste artifact, but it looks like you're missing one backslash: my $VSS= '"D:\Program ... should be my $VSS= '"D:\\Program ...

    HTH

      'A\B' and 'A\\B' mean the same thing. Only \' and \\ have special meanings in a single-quoted string; other single backslashes are unchanged and non-special.

Re: 'system' not working!
by dws (Chancellor) on Oct 25, 2001 at 01:40 UTC
    This used to work! I updated the paths to reflect my current situation, ...

    By "paths" do you mean $VSS, or $ENV{PATH}? Either could have an effect. It might help to characterize the change (e.g., what was the old value?)

      "paths" meaning where VS.exe is, where the repository is, where my project files are. They are hard-coded into the script, like the $VSS.
Re: 'system' not working!
by John M. Dlugosz (Monsignor) on Oct 24, 2001 at 23:56 UTC
    Update: the single backslash at the beginning of the string is OK, because this is single-quoted. I changed it to be consistant, and it didn't matter.

    Here is the actual error text: Can't spawn "cmd.exe": No such file or directory at d:\program files\util\manage_vss.perl line 22.