Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 258339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:10:20+00:00 2026-05-11T22:10:20+00:00

My original script is as follows: my $cmd = dir; open (H, $cmd |);

  • 0

My original script is as follows:

my $cmd = "dir";
open (H, "$cmd |");
my @result = <H>;
close (H);
print STDERR @result,"\n";

This scripts works fine. If I add following line to the script, it fails to work:

$ENV{"LD_LIBRARY_PATH"} = "/opt/VRTSsfmh/lib";
$ENV{PATH}="/usr/bin:/bin:/sbin:/usr/sbin";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};

What does Perl use when pipe open is called?

Addition of following code fixed the issue:

if ($^O =~ /Win32/i) 
{
    $ENV{'SystemRoot'} =~ /([A-Z]:(\\[A-Za-z0-9_]+)+)/;
    my $system32_dir = $1."\\system32";
    $ENV{'PATH'} = $system32_dir;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:10:21+00:00Added an answer on May 11, 2026 at 10:10 pm

    Your question is not really related to taint mode. You set

    $ENV{PATH}="/usr/bin:/bin:/sbin:/usr/sbin";
    

    These directories do not normally exist on a Windows machine. dir is a cmd.exe internal command so to be able to execute that, you need to add the directory where it resides to the path.

    Now, note that the way you go about doing it contradicts the whole point of setting the path to known definite locations. It is definitely possible for a nefarious user to change this environment variable to point to his dangerous version of dir.

    The fact that Windows is not necessarily installed in C:\Windows complicates writing a taint-safe script on Windows if you rely on any of the shell builtins.

    EDIT: Here is a short test program you can use as a baseline:

    #!/usr/bin/perl -T
    
    use strict;
    use warnings;
    
    $ENV{PATH} = join(';', qw(C:\Windows C:\Windows\System32) );
    delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
    
    open my $pipe_h, '-|', 'dir'
        or die "Cannot open pipe to dir: $!";
    
    print while <$pipe_h>;
    
    close $pipe_h
        or die "Cannot close pipe to dir: $!";
    
    __END__
    
    C:\Temp> perl -T v.pl
    
    ...
    
    2009/05/25  08:58 AM             3,584 zzz.exe
                  64 File(s)     32,125,365 bytes
                  14 Dir(s)  39,251,894,272 bytes free
    

    Basically, what you need is for the system administrator to hardcode the acceptable path at installation time and for untrusted users not to have write permissions on the script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The 2 machines might have different warning levels or error… May 12, 2026 at 12:36 am
  • Editorial Team
    Editorial Team added an answer Store the users IP in a database every time the… May 12, 2026 at 12:36 am
  • Editorial Team
    Editorial Team added an answer Take a look at Python Eggs: http://peak.telecommunity.com/DevCenter/PythonEggs Or, you can… May 12, 2026 at 12:36 am

Related Questions

G'day, This is related to my question on star developers and to this question
Trying to follow a technique found at bzr and gitosis I did the following:
I ran Perl::Critic on one of my scripts, and got this message: Regular expression
A while ago I had asked how to make a collapsible comment box like

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.