http://www.perlmonks.org?node_id=1043176


in reply to Setting a library path (export) to call SSH

I think what you have to do is set an environment variable from within perl, which you can do quite easily. There is a special hash variable called %ENV that you set like this:
$ENV{LIBPATH} = "/opt/freeware/lib:/opt/freeware/64/lib:/usr/lib:$ENV{ +LIBPATH}";
Best of luck!

(Note that using backticks to do something like `export LIBPATH=/opt/freeware/lib:/opt/freeware/64/lib:/usr/lib:$LIBPATH` launches a shell, sets the environment variable in that shell, then quits, which doesn't do you much good.)

Replies are listed 'Best First'.
Re^2: Setting a library path (export) to call SSH
by Preceptor (Deacon) on Jul 08, 2013 at 20:18 UTC

    You can, if you _really_ must encapsulate the setting environment into the 'backticks'.

    my $result = `set LIBPATH=/opt/freeware/lib:/opt/freeware/64/lib; ssh +$host stuff`;

    It's probably better to configure %ENV though. Any may be better yet to fix your library paths though - ssh is something that'd probably benefit from being 'properly installed' into the environment. Maybe even by replacing your ssh binary (in your path) with a wrapper script, in /usr/bin or similar. It may be worth doing a (non packaged) install of ssh, so you can install your own libs in the right places.

Re^2: Setting a library path (export) to call SSH
by MidLifeXis (Monsignor) on Jul 09, 2013 at 12:31 UTC

    Or to isolate the LIBPATH setting to just where needed...

    { local $ENV{LIBPATH} = "/opt/freeware/lib:/opt/freeware/64/lib:/usr/l +ib:$ENV{LIBPATH}"; # execute ssh command here }

    --MidLifeXis

      Thank you all for the wisdom and suggestions, much appreciated!!