我怎样才能提交网格作业时控制所使用的Perl版本? [英] How can I control the Perl version used when submitting grid jobs?

查看:143
本文介绍了我怎样才能提交网格作业时控制所使用的Perl版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和SGE(Sun Grid Engine的)工作将作业提交到网格。我还用 perlbrew 来管理我的Perl安装版本。
我写的,我用它来运行它需要一个特定的Perl版本(5.12.2),它看起来像这样的Perl脚本一些短期 SH 脚本:

I'm working with SGE (Sun Grid Engine) to submit jobs to a grid. I also use perlbrew to manage my installed Perl versions. I wrote some short sh scripts that I use to run a perl script which requires a specific Perl version (5.12.2), which look something like this:

#!/bin/bash
#$-S /bin/bash

source /home/dave/.bash_profile
/home/dave/perl5/perlbrew/bin/perlbrew switch perl-5.12.2

/home/dave/scripts/proc_12.pl --in=/home/dave/in/in.store --dir=/home/dave/in/dir2 --params=/home/dave/in/params.p

现在,当我提出一个单一的工作一切正常,但是当我提出很多,我开始越来越 perlbrew 相关的错误信息,如:

Now, when I submit a single job everything works fine, but when I submit many, I start getting perlbrew related error messages, like:

ln: creating symbolic link `current' to `perl-5.12.2': File exists
ln: creating symbolic link `/home/dave/perl5/perlbrew/bin/cpan' to `/home/dave/perl5/perlbrew/perls/current/bin/cpan': File exists
ln: creating symbolic link `/home/dave/perl5/perlbrew/bin/cpan2dist' to `/home/dave/perl5/perlbrew/perls/current/bin/cpan2dist': File exists
ln: cannot remove `/home/dave/perl5/perlbrew/bin/cpanp': No such file or directory
ln: cannot remove `/home/dave/perl5/perlbrew/bin/enc2xs': No such file or directory
ln: cannot remove `/home/dave/perl5/perlbrew/bin/find2perl': No such file or directory

所以我想在 /家庭/戴维/的perl5 / perlbrew /斌/ perlbrew开关的Perl 5.12.2 线引起的问题。

我该怎么办?

我怎么可以用perl-5.12.2我的脚本运行(默认为5.8.8)?

How can I make my script run using perl-5.12.2 (the default is 5.8.8)?

推荐答案

我不建议把 perlbrew切换的Perl 5.12.2 在你运行任何脚本。它真的只有命令行用法。

I don't recommend putting the perlbrew switch perl-5.12.2 in any script you run. Its really only for command line usage.

如果你需要一个脚本使用Perl特定版本然后要么给它的家当全 perlbrew 路径:

If you need a script to use a specific version of Perl then either give it the full perlbrew path on the shebang:

#!/home/dave/perl5/perlbrew/perls/perl-5.12.2/bin/perl

use 5.012;
use warnings;
...

然后确保它的可执行文件并运行,像这样:

Then make sure its executable and run like so:

chmod +x your_perl_program.pl
./your_perl_program.pl

或者另外也可以使用完整路径名的perl程序在你的脚本:

Or alternatively use the full pathname to the perl binary in your script:

#!/bin/bash

/home/dave/perl5/perlbrew/perls/perl-5.12.2/bin/perl your_perl_program.pl

结果
顺便说一句,如果你运行任何东西在你的脚本或Perl程序不合格的你将有潜在的生产和安全问题。对于例如:


BTW, you will have potential production and security issues if you run anything unqualified in your scripts or perl programs. For eg:

#!/bin/sh

# security risk
perl some_script.pl

# and not just perl
tar cvf archive.tar *.txt

# production risk
/home/dave/perl5/perlbrew/bin/perl some_other_script.pl

前两个是坏的,因为它会拿起第一个 perl的&安培; 焦油发现在你的路径。因此,这取决于 $ PATH 设置,这可能成为一个安全隐患。最后也是不好的,因为它在什么perl的 perlbrew 在时间点目前切换到其运行依赖:(

The first two are bad because it will pick up the first perl & tar it finds in your path. So this depends on $PATH setting and this could become a security risk. The last is also not good because its reliant on what perl perlbrew is currently switched to at the point in time its run :(

这样算下来这可能是一个潜在的生产和放大器;安全噩梦。相反,上述应该这样写:

So doing this can be a potential production & security nightmare. Instead the above should be written like this:

#!/bin/sh

# fully qualified now.  Uses OS provided perl
/usr/bin/perl some_script.pl

# ditto
/usr/bin/tar cvf archive.tar *.txt

# this needs to run in perl 5.12.2
/home/dave/perl5/perlbrew/perls/perl-5.12.2/bin/perl some_other_script.pl

希望各有道理?

/ I3az /

这篇关于我怎样才能提交网格作业时控制所使用的Perl版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆