in reply to Re: [OT] sudo does not execute .profile
in thread Perl sudo does not execute .profile

Thank you for your reply. I really appeciate the help ! This is a very odd problem. Here's the entire story... We connect remotely from an automated test script written in VBscript to a common test account on an AIX server. The VBscript simulates an interactive user login so the AIX server thinks someone is logging in and executing our first Perl script manually. This first Perl script calls Perl sudo with the -i option to execeute a second Perl script under a different uid and gid. Well now the .profile successfully executes (yeah!... I put an echo debug statement in there to be sure), but, (and this is the really strange part) when the second Perl script executes the environment variables defined in the .profile are no longer defined !!! I know this because at the top of the second Perl script I print out the important environment variables (print $ENV{'CLASSPATH'};) and they are all empty. Why??
  • Comment on Re^2: [OT] sudo does not execute .profile

Replies are listed 'Best First'.
Re^3: [OT] sudo does not execute .profile
by afoken (Chancellor) on Nov 14, 2010 at 16:58 UTC

    I think this is a Unix / AIX problem, not a Perl problem. Perhaps (a) missing export command(s) in .profile? Run env (or see below) instead of the second script and look at the output. Post the .profile file, if it does not contain sensitive data. Also post the relevant parts of the perl scripts.

    Simple env replacement:

    #!/usr/bin/perl -w use strict; use Data::Dumper; print Data::Dumper->new([\%ENV],['*ENV'])->Useqq(1)->Sortkeys(1)->Dump +();

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      Perhaps (a) missing export command(s) in .profile?

      .profile is only processed by login shells, thus the solution is to create a login shell.