Perl/Example

From ScientificComputing
Revision as of 10:47, 27 October 2016 by Sfux (talk | contribs) (Created page with "As an example for a Perl job, we are looking at a script, that prints all environment variables for the current shell. [leonhard@euler04 ~]$ '''cat test.pl''' #!/usr/bin/e...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

As an example for a Perl job, we are looking at a script, that prints all environment variables for the current shell.

[leonhard@euler04 ~]$ cat test.pl 
#!/usr/bin/env perl

# This script prints out all environment varibles of the current shell.
my @keys = keys(%ENV);
while(my $key = shift @keys) {
        print "$key=$ENV{$key}\n";
}
[leonhard@euler04 ~]$ module load new gcc/4.8.2 perl/5.16.3
Now run 'perl-init' to initialize your environment for Perl
[leonhard@euler04 ~]$ perl-init
[leonhard@euler04 ~]$ bsub -n 1 -W 0:30 -R "rusage[mem=10]" perl test.pl   
Generic job.
Job <30746346> is submitted to queue <normal.4h>.
[leonhard@euler04 ~]$ bjobs
JOBID      USER        STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
30746346   leonhard    PEND  normal.4h  euler04                 *l test.pl Oct 27 12:33
[leonhard@euler04 ~]$ bjobs
JOBID      USER        STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
30746346   leonhard    RUN   normal.4h  euler04     e1243       *python.py Oct 27 12:35
[leonhard@euler04 ~]$ bjobs
No unfinished job found
[leonhard@euler04 ~]$ grep PERL lsf.o30746346 
PERLBREW_MANPATH=/cluster/apps/perl5/perls/perl-5.16.3/man
PERLBREW_VERSION=0.73
PERLBREW_PATH=/cluster/apps/perl5/bin:/cluster/apps/perl5/perls/perl-5.16.3/bin
PERLBREW_ROOT=/cluster/apps/perl5
PERLBREW_PERL=perl-5.16.3
PERLBREW_BASHRC_VERSION=0.73

The output of the Perl script is written to the lsf.o30746346 file.