Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: replicating the command 'unset LIBPATH' in perl

by viffer (Beadle)
on May 18, 2010 at 05:03 UTC ( #840449=note: print w/replies, xml ) Need Help??


in reply to Re: replicating the command 'unset LIBPATH' in perl
in thread replicating the command 'unset LIBPATH' in perl

Thanks for pointing out that unset is a shell command. I come from a mainframe background (please don't laugh) and will readilly admit to getting thoroughly confused between the various shells etc. I had tried the
delete $ENV{LIBPATH}
and it's right near the top of script.

The weird thing is, that whilst it does replicate the unset command on going into the called routine, unlike the unset command it still causes a 'Total Environment allocation failure'.

I realize this is now getting off of perl per se and more into shell commands - but I beg your indulgence, does 'unset LIBPATH' do anything other than delete the path?

I did a comparison of env before and after issuing the command, and aside of the LIBPATH no longer being present, the only other difference was addition of the phrase "SHLVL=1".

Appreciate your time in responding.

Replies are listed 'Best First'.
Re^3: replicating the command 'unset LIBPATH' in perl
by ikegami (Patriarch) on May 18, 2010 at 05:57 UTC

    I had tried the delete $ENV{LIBPATH} and it's right near the top of script.

    You missed the part about using BEGIN. The idea is to execute it before any use statements are executed, and you'll need BEGIN for that.

    BEGIN { delete $ENV{LIBPATH} }
      Again thanks. I have put it in a BEGIN statement - and again, whilst it does appear to unset the libpath, it doesn't enable me to connect to the database. The *only* command that seems to work is running unset LIBPATH prior to running the script.

      It would seem the super user account has the db2profile as default environment.

      It runs both applications which require db2inst1 profile (db2 v8) and db2inst2 profile (db2 v9).

      The thought is now to consider setting db2profile env before app start and not having db2profile in the super user profile - although the person charged with doing that seems overly reticent (without giving his reasons) to do it.

      Cheers for your help

        This should work
        #!/usr/bin/perl -- BEGIN { unless( $ENV{ +__FILE__ } eq __FILE__ ){ delete $ENV{LIBPATH}; $ENV{ +__FILE__ } = __FILE__; exec $^X, __FILE__, @ARGV; # relaunch without LIBPATH } } ...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://840449]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2022-05-23 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?