A
Adam-the-Kiwi
Hi All,
Fairly newbie question - apologies in advance if this is covered in
FAQs, but I can't find it on CPAN or perldoc.
Essentially, I'm writing a perl script to do some ClearCase trigger
processing. This trigger will fire on a variety of ClearCase actions
and execute a perl script - perl because of the ease of writing
functionality that works on UNIX and Windoze platforms.
I've written a little wrapper to simulate the trigger firing to allow
me to test my funtionality on my laptop at home, which doesn't have
ClearCase installed. Essentially, all this does is set the appropriate
environment variables and then calls the perl script, testing for the
returned value. The perl script in question does some stuff, calls a
subroutine and then passes that subroutine's return value (0 for
success) back up using exit. The wrapper simply prints out the
returned value so I can make sure that the processing is working as it
should.
Except that it doesn't. What I suspect is happening is that I'm
testing the return value of 'perl' rather than the script it executes.
Is that right? Can I access the scripts' return value instead?
Note: it doesn't really matter, because, as you can see, I'm printing
out the return anyway - I'm just curious, like...
Cheers - Adam...
Cradle:
#===============================================================================
#
# Name: trigger_wrapper.pl
# Author: Adam Cheney
# Description: wrapper for testing triggerware
#
#===============================================================================
use strict;
#use diagnostics;
# Set environment up:
$ENV{'CLEARCASE_OP_KIND'} = 'checkin';
$ENV{'CLEARCASE_TRTYPE_KIND'} = 'pre-operation';
$ENV{'OS'} = undef;
$ENV{'CLEARCASE_ELTYPE_NAME'} = 'file';
$ENV{'CLEARCASE_COMMENT'} =
'(AWC)8954-GXS;15599-CXM;17273-SDF;S4012-GXT: another good one.\n';
$ENV{'CLEARCASE_USER'} = undef;
my $system_return = system ("perl IMtrig.pl");
print "\nReturn value is: $system_return";
Perl script:
#===============================================================================
#
# Name: IMtrig.pl
# Author: Adam Cheney
# Description: Central entry point for all IM trigger processing
#
#===============================================================================
use strict;
#use diagnostics;
use ETCccutil;
use ETCtrigfunc;
# Define location of exported DID text file
my $DID_file = "cds_28Oct_17h41.txt";
# Define reference to anonymous hash laying out actions matrix
my $matrix = {'checkout' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'checkin' => {'preop' => \&ETCtrigfunc:recheckin,
'postop' => \&ETCtrigfunc::noaction},
'mkelem' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'uncheckout' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'reserve' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'unreserve' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'chevent' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'rmelem' => {'preop' => \&ETCtrigfunc:rermelem,
'postop' => \&ETCtrigfunc::noaction},
'rmver' => {'preop' => \&ETCtrigfunc:rermver,
'postop' => \&ETCtrigfunc::noaction},
'rmbrnach' => {'preop' => \&ETCtrigfunc:rermbranch,
'postop' => \&ETCtrigfunc::noaction}};
my $action = ""; # The action that invoked the trigger
my $sequence = ""; # preop or postop
($action, $sequence) = &ETCccutil::gettrigger;
# Call the appropriate function
my $trigreturn = &{$matrix->{$action}->{$sequence}} ($DID_file);
print "...and the return value is $trigreturn\n";
exit ($trigreturn);
Fairly newbie question - apologies in advance if this is covered in
FAQs, but I can't find it on CPAN or perldoc.
Essentially, I'm writing a perl script to do some ClearCase trigger
processing. This trigger will fire on a variety of ClearCase actions
and execute a perl script - perl because of the ease of writing
functionality that works on UNIX and Windoze platforms.
I've written a little wrapper to simulate the trigger firing to allow
me to test my funtionality on my laptop at home, which doesn't have
ClearCase installed. Essentially, all this does is set the appropriate
environment variables and then calls the perl script, testing for the
returned value. The perl script in question does some stuff, calls a
subroutine and then passes that subroutine's return value (0 for
success) back up using exit. The wrapper simply prints out the
returned value so I can make sure that the processing is working as it
should.
Except that it doesn't. What I suspect is happening is that I'm
testing the return value of 'perl' rather than the script it executes.
Is that right? Can I access the scripts' return value instead?
Note: it doesn't really matter, because, as you can see, I'm printing
out the return anyway - I'm just curious, like...
Cheers - Adam...
Cradle:
#===============================================================================
#
# Name: trigger_wrapper.pl
# Author: Adam Cheney
# Description: wrapper for testing triggerware
#
#===============================================================================
use strict;
#use diagnostics;
# Set environment up:
$ENV{'CLEARCASE_OP_KIND'} = 'checkin';
$ENV{'CLEARCASE_TRTYPE_KIND'} = 'pre-operation';
$ENV{'OS'} = undef;
$ENV{'CLEARCASE_ELTYPE_NAME'} = 'file';
$ENV{'CLEARCASE_COMMENT'} =
'(AWC)8954-GXS;15599-CXM;17273-SDF;S4012-GXT: another good one.\n';
$ENV{'CLEARCASE_USER'} = undef;
my $system_return = system ("perl IMtrig.pl");
print "\nReturn value is: $system_return";
Perl script:
#===============================================================================
#
# Name: IMtrig.pl
# Author: Adam Cheney
# Description: Central entry point for all IM trigger processing
#
#===============================================================================
use strict;
#use diagnostics;
use ETCccutil;
use ETCtrigfunc;
# Define location of exported DID text file
my $DID_file = "cds_28Oct_17h41.txt";
# Define reference to anonymous hash laying out actions matrix
my $matrix = {'checkout' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'checkin' => {'preop' => \&ETCtrigfunc:recheckin,
'postop' => \&ETCtrigfunc::noaction},
'mkelem' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'uncheckout' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'reserve' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'unreserve' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'chevent' => {'preop' => \&ETCtrigfunc::noaction,
'postop' => \&ETCtrigfunc::noaction},
'rmelem' => {'preop' => \&ETCtrigfunc:rermelem,
'postop' => \&ETCtrigfunc::noaction},
'rmver' => {'preop' => \&ETCtrigfunc:rermver,
'postop' => \&ETCtrigfunc::noaction},
'rmbrnach' => {'preop' => \&ETCtrigfunc:rermbranch,
'postop' => \&ETCtrigfunc::noaction}};
my $action = ""; # The action that invoked the trigger
my $sequence = ""; # preop or postop
($action, $sequence) = &ETCccutil::gettrigger;
# Call the appropriate function
my $trigreturn = &{$matrix->{$action}->{$sequence}} ($DID_file);
print "...and the return value is $trigreturn\n";
exit ($trigreturn);