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

Ok then, let's see what your .profile does:

1. Paragraph
does setting for interactive session probably not needed for your batch task.

2. Para
does settings for SID ISWLIVE wich is default for interctive sessions.

3. Para
for interactive sessions. Maybe TWO_TASK should be exported too as this is ORA related.

Next 3 Para
these aliases can be used after execution of .profile to set environment (temporarily) to a different DB-SID.

Conclusion
call in a row .profile (and one of the aliases if you don't need the default SID). This should set up a environment you can use as a base for your batch actions.

pelagic

Replies are listed 'Best First'.
Re^10: Unix Aliases?
by Ronnie (Scribe) on Sep 09, 2004 at 09:10 UTC
    Sorry to be a complete dummy - that doesn't usually stop me! - I understand & agree with your analysis of this script but..... When getenv is run against this file TWO_TASK is omitted and I can't see a reason why. (I removed the semi-colon and it still didn't appear). I am also confused about your Conclusion; I can certainly execute the .profile as a "system" call but I am unaware of a means to access an alias in Perl can this be done or were you referring to UNIX here? Cheers, Ronnie
      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
        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