Environment variables not working in Perl -
i trying set environment variables in perl @ origin of program, maintain receiving errors unless set them in bash script calls perl script.
#!/usr/bin/perl -w $env{'oracle_home'}='path'; $env{'ld_library_path'}='path';
this not work, shell script does:
#!/bin/bash export oracle_home=path export ld_library_path=path ./perlscript.pl
i setting these paths in order dbi module work. ideally, set paths in perl script , not utilize bash script.
error:install_driver (oracle) failed: can't load /some/path/ module dbd:oracle: libclntsh.so.11.1: cannot open shared object file: no such file or directory @ /some/path/dynaloader.pm line 230
codeuse dbi; $dbh = dbi->connect("dbi:oracle:host=something;port=something;sid=something"); $sth = $dbh->perepare($query); $sth->execute(); $sth->finish();
iirc, it's because c library makes own re-create of environment and/or because ld_library_path
used when executable loaded. workaround:
#!/usr/bin/perl -w if (!$env{oracle_home}) { $env{oracle_home} = 'path'; $env{ld_library_path} = 'path'; exec($^x, '--', $0, @argv); } ...
in case i'm wrong, seek next first. makes sure environment vars set before modules utilize them loaded.
#!/usr/bin/perl -w begin { $env{oracle_home} = 'path'; $env{ld_library_path} = 'path'; } ...
perl variables environment dbi dbd
No comments:
Post a Comment