Re: FindBin cannot chdir back problem



"Sisyphus" <sisyphus1@xxxxxxxxxxxxxxxxx> wrote in message
news:42d5bd45$0$3275$afc38c87@xxxxxxxxxxxxxxxxxxxxxxx
>
> "bxb7668" <brian@xxxxxxxxxxxxxxxxxxxxx>
>
>> Here is a code snippet from my script that calls FindBin:
>>
>> #!/bin/perl
>> use strict;
>> use File::Basename;
>> use Getopt::Long;
>> use Cwd;
>> use Cwd 'abs_path';
>> require 5.6.1;
>>
>> # ------------------------------------------------
>> $ENV{PATH} = my $UT_MYPATH = my $UT_CCPATH = "";
>> delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
>
> Are the above 2 lines relevant to the problem ? If so, let us know. If
> not,
> let us know. If you don't know, remove them and then check to see what
> happens.
>
>>
>> # In the original script, the following line is line 101
>> use FindBin qw($Bin);
>> BEGIN { # Untaint $Bin
>> if ( "$Bin" =~ /^(.*)$/ ) { $Bin = $1; } else { die "Tainted
>> Bin\n";};
>> }
>> use lib ("${Bin}/perllib","${Bin}/../perllib");
>>
>> require 'bvb_include_common.pl';
>> bvb_set_PATH($Bin, $BVBDEBUG); # Set PATH to min. system libs
>>
>> exit(0);
>
> Not sure how you expect that to help us. Normally, when someone asks
> for
> code, a minimal example is provided. Your script seems to be failing
> at
> compile time - in which case, just about all the code that you have
> supplied
> is superfluous. I suspect that the problem can be produced by running
> the
> following script (if that script is in the same location as
> trigger.pl):
>
> use FindBin qw($Bin);
> __END__
>
> The problem is probably as Slaven said.
>
Sorry if I provided too much information. I've more often had people
want to see the entire script. Anyway, I tried your suggested one-liner
and FindBin worked fine. In fact, after having my script fail every
time on Tuesday and Wednesday, today it has started working without any
problems. The use says that he didn't change anything. Go figure. I
hate intermittent and/or unreproducible problems.

Thank you for taking a look.
Brian


.



Relevant Pages

  • Re: FindBin cannot chdir back problem
    ... > Here is a code snippet from my script that calls FindBin: ... > use strict; ... > use Cwd 'abs_path'; ...
    (comp.lang.perl.modules)
  • What directory perl script is being run from? - followup
    ... Cwd didn't work because it gives what directory ... Can't get FindBin to work..any idea what's wrong with the following? ... normally..just doing a quick hack to someone else's script! ...
    (comp.lang.perl)
  • Re: Not able to open a file.
    ... but i dont ... use warnings; ... script is.) ... use FindBin '$Bin'; ...
    (perl.beginners)
  • Re: Not able to open a file.
    ... my script is.. ... the $Bin path', as the value of $Bin would be interpolated into the file string. ... What FindBin ... your program's current working directory is not the directory containing the ...
    (perl.beginners)
  • Re: FindBin cannot chdir back problem
    ... Here is a code snippet from my script that calls FindBin: ... use Cwd 'abs_path'; ...
    (comp.lang.perl.modules)