#!/opt/appenv/perl/bin/perl use strict; use warnings; use CGI; use Data::Dumper; my $q = new CGI; print $q->header(); my %ENV2; %ENV2 = (%ENV2, get_login_env()); print Dumper(\%ENV2); sub get_login_env { local %ENV; my $shell= '/usr/bin/ksh'; #shift || (getpwuid($<))[8]; my $env = `echo env | /opt/appenv/perl/bin/perl -e 'exec {"$shell"} -sh'`; if (wantarray) { my @pieces = ($env =~ m/^(.*?)=((?:[^\n\\]|\\.|\\\n)*)/gm); s/\\(.)/$1/g foreach @pieces; return @pieces; } else { return $env; } }