<div class="section" id="native-perl-tasks"> <p>Here is an example of a script as a local native perl task</p> <ul class="simple"> <li>definition file:</li> </ul> <div class="highlight-python"><pre> task perl edit ECF_MICRO '^' edit ECF_JOB_CMD '^ECF_JOB^ > ^ECF_JOBOUT^ 2>&1' label info "none" meter step -1 100 100 event 1 event 2</pre> </div> <ul class="simple"> <li>headers:</li> </ul> <div class="highlight-python"><pre>#!/usr/bin/env perl # head.pl use strict; my $ECF_PORT=^ECF_PORT:0^; $ENV{'ECF_PORT'} = "^ECF_PORT:0^"; # port $ENV{'ECF_NODE'} = "^ECF_NODE:0^"; # host $ENV{'ECF_NAME'} = "^ECF_NAME:0^"; # task path $ENV{'ECF_PASS'} = "^ECF_PASS:0^"; # password $ENV{'ECF_TRYNO'} = "^ECF_TRYNO:0^"; # job number sub xinit() { system("ecflow_client --init $$"); } sub xabort() { system("ecflow_client --abort $$"); } sub xcomplete() { system("ecflow_client --complete $$"); } sub xmeter($$) { my $name=shift; my $value=shift; system("ecflow_client --meter $name $value"); } sub xevent($) { my $n=shift; system("ecflow_client --event $n"); } sub xlabel($$) { my $name=shift; my $value=shift; system("ecflow_client --label $name $value"); } xinit(); eval ' </pre> </div> <div class="highlight-python"><pre># tail.pl '; if ($@){ print "caught signal: $@\n"; xabort(); exit; } print "the job is now complete\n"; xcomplete(); exit; </pre> </div> <ul class="simple"> <li>task wrapper:</li> </ul> <div class="highlight-python"><pre>#!/usr/bin/perl -w # perl.ecf ^include <head.pl> ^manual one liner manual ^end ^comment one liner comment ^end xlabel("info", "start"); xevent("1"); print "a perl task"; for (my $step=1; $step <= 100; $step++) { print "this is the step number $step\n"; xmeter("step", $step); } xevent("2"); xlabel("info", "completion"); ^include <tail.pl> </pre> </div> </div> |