in reply to (tye)Re: Security concern with sudo and system()
in thread Security concern with sudo and system()

On Windows, it will look for the contents of $ENV{PERL5SHELL} for a complete string (command name and switches) that it prepends to the string you are running.

If that environment variable does not exist, it uses either "CMD.EXE /X/C" or "COMMAND.COM /C" depending one whether it's running NT or Win9x.

Having different shells on Win9x vs NT can expose differences, since CMD with the /X switch does more than COMMAND.COM.

I know Perl used to use $ENV{COMSPEC} because I relied on the capabilites of my shell (the one that invoked the perl script in the first place) and found it broke at some point. That's when I learned about PERL5SHELL. I seem to recall that there was also some "common" min-shell shipped with activestate Perl at some point, to prevent differences between 9x and NT.

—John

Replies are listed 'Best First'.
(tye)Re: $ENV{PERL5SHELL}
by tye (Sage) on Sep 16, 2001 at 08:56 UTC

    Yes, I have vague memories of long ago Perl using $ENV{SHELL} for system under Unix and that being fixed.

    One of the reasons that building modules from CPAN doesn't work well under Win9x is that 2>&1 doesn't work in COMMAND. I realize now that the fix for this is IPC::Open2.

    And now I've drifted way off the original topic. (:

            - tye (but my friends call me "Tye")
      Re off topic: so change the topic.

      In the shell I use on Windows, command >& output redirects both stdout and stderr. I think something like what you show works too, but I'd have to look up the syntax details.

      Who needs a shell? Do it all in Perl, and run external programs when you need them but don't rely on the shell to do anything for you. Instead do the same stuff in Perl! Like you point out, redirect the output. Also, do globbing, directory listing, etc. all in Perl and then just call the program. That's a path I've taken, because COMMAND.COM isn't worthy of the name shell and using a real shell is non-portable.

      —John