in reply to windows command line problem?

The usual advice would be to use

exec( "c:/program files/Internet explorer/IEXPLORE.EXE", $url, );
to avoid command-line shell misinterpretation risks. Unfortunately, that trick doesn't work in Win32 and Perl doesn't (yet -- I still have hope) make it even "almost work".

I'd go with: $command = qq("C:/Program Files/Internet Explorer/IEXPLORE.E­XE" "$url"); because you need quotes around the URL because & has meaning to the shell just like the spaces do (which is what forced you to put quotes around the path to IE).

        - tye (but the shell thinks I'm Tye)

Replies are listed 'Best First'.
Re: (tye)Re: windows command line problem?
by xafwodahs (Scribe) on Oct 16, 2002 at 20:01 UTC
    I tried your qq... method - in fact, I copied and pasted to make sure I didn't have a typo, and for reasons I have yet to understand, it failed to open internet explorer. I put a "sleep 10" before the exec, so I could make sure the command looked good, which it did to me...

      Sorry, the code inside of perl.exe that gets run is convoluted (it converts the arguments to exec into a string which it then converts into a list of command words, which are then converted back into a string, *sigh*) and rather buggy. It has also changed between versions of Perl so exactly what works depends on what version of Perl you have.

      You could use Win32::Process which gives you much more direct access to what exec ends up calling anyway.

      But, you can also just avoid quotes around the executable name which appears to be what triggers several of the bugs. Luckily, these are easy to avoid by using Win32::GetShortPathName():

      use strict; use Win32; my $date = sprintf("%04d%02d%0d", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3] ); my $url = "www.moviefone.com/showtimes/closesttheaters.adp?date=$date\ +&skip=5"; my $command = Win32::GetShortPathName( "C:/Program Files/Internet Explorer/IEXPLORE.EXE" ); $command = qq($command "$url"); print "$command"; ''.<STDIN>; exec( $command );
      which I tested. (:

              - tye ('Tye' is not recognized as an internal or external command)