ecFlow's documentation is now on readthedocs!

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Here is an example of a script as a local native perl task

  • definition file:
   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
  • headers:
#!/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 '
# tail.pl
';
if ($@){
    print "caught signal: $@\n";
    xabort();
    exit;
  }
print "the job is now complete\n";
xcomplete();
exit;
  • task wrapper:
#!/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>
  • No labels