| 1 |
#!/usr/bin/perl -w |
| 2 |
# |
| 3 |
# ecaccess: Helper to start any ecaccess command from the PAR archive |
| 4 |
# |
| 5 |
# [email protected] - 2012-02-09 |
| 6 |
|
| 7 |
use ECMWF::ECaccess; |
| 8 |
use Getopt::Long; |
| 9 |
use Pod::Usage; |
| 10 |
use IPC::System::Simple qw(system capture); |
| 11 |
|
| 12 |
my $commandName = $ARGV[0]; |
| 13 |
my $dataDir = $ENV{PAR_TEMP}; |
| 14 |
|
| 15 |
die "No command name specified!\n" if not($commandName); |
| 16 |
die "Not called from a PAR archive\n" if not($dataDir); |
| 17 |
|
| 18 |
# Remove command name from args |
| 19 |
shift(@ARGV); |
| 20 |
|
| 21 |
# Define the filename of the script |
| 22 |
my $command = "$dataDir\\inc\\script\\$commandName"; |
| 23 |
|
| 24 |
# Check if the command exists |
| 25 |
die "Command $commandName not found!\n" if ( not( -e $command ) ); |
| 26 |
|
| 27 |
# Run the requested ecaccess command |
| 28 |
eval { $exitCode = system( $^X, $command, @ARGV ); }; |
| 29 |
|
| 30 |
# Return exit code from command |
| 31 |
exit($exitCode); |