in reply to Re^10: Unix Aliases?
in thread Unix Aliases?

Your ".profile" is setting the variable TWO_TASK to a value but it's nor exporting it. After ".profile" has finished TWO_TASK will not be available anymore. So if you have to have it export it also.

A statement in ksh is finished either by the end of the line or by a ";" if you want to code more than 1 stmt on 1 line.

I my conclusion I meant you could call:
my @envlines = (`exec ksh -c ". .profile; ISWTEST; env"`);
This should set all vars in .profile and then change some to different values as in the specified alias "ISWTEST" and then finally grab everything as described earlier.

pelagic

Replies are listed 'Best First'.
Re^12: Unix Aliases?
by Ronnie (Scribe) on Sep 09, 2004 at 09:44 UTC
    You were absolutely spot on regarding the non-export of TWO_TASK being the problem. The alias doesn't work though; I didn't think it would as when the .profile is processed via the ksh the lines referring to the aliases are not actioned. ( I put a print in for each of the elements in @envlines and they didn't show up). When the call to the alias is made the shell reports - ksh: ISWTEACH: not found. The toy town test script that I'm using follows -
    #!/usr/bin/perl -w # use lib "/home/interface/scripts/Perl_Modules" ; # sub getenv { my $profile = shift; my @envlines = (`exec ksh -c ". $profile; ISWTEACH; env"`); open OPF, ">myxxrcdata" or die "\n\tBugger: $!\n" ; foreach (@envlines) { chomp; next unless /=/; print "$_\n" ; # No alias lines appear print OPF "$_\n" or die "\n\tIt's nae use captin: $!\n" ; my ($var, $value) = split(/=/, $_, 2); $ENV{$var} = $value; } # close OPF or die "\n\tShit... I mean oh Dear!\n" ; # return 1 ; # } # END - getenv # #################################### # Variables # #################################### # $file = '/home/rcruickshank/Perl/xxrc_inter_prof.pl' ; # #################################### # Processing # #################################### # print "\n\t<***** SOR *****>\n" ; # getenv("$file") or die "\n\tIt didnae run min! : $!\n" ; # print "\n\tOracle SID :: $ENV{ORACLE_SID}\n" ; # print "\n\t<***** EOR *****>\n" ;
    If it's not something obviously stupid that I'm doing I think I'll just use the boring 3 hash tables idea. Thanks for all your help, Ronnie