【问题标题】:Pass a hash object from a perl script to through bsub (LSF)将哈希对象从 perl 脚本传递到 bsub (LSF)
【发布时间】:2015-10-13 13:56:09
【问题描述】:

这是对我以前的问题的扩展:Pass a hash object from one perl script to another using system。 @Sobrique 在那里回答了我的问题。

现在,我想知道是否可以以与我上面的问题相同的方式将哈希对象传递给另一个 perl 脚本,但使用 bsub

包装脚本:script1.pl

use strict;
use warnings;
use Storable qw ( freeze  );
use MIME::Base64;

my %test_hash = (
    "fish"   => "paste",
    "apples" => "pears"
);

my $frozen = encode_base64 freeze( \%test_hash );
my ${string} = 'sample1';

# instead of just using system like this
# system("perl", "some_other_script.pl", $frozen);
# I want to use something like this:
system('bsub','-J',${string},'-o','${string}.out','-e','${string}.err','perl','some_other_script.pl',$frozen);

some_other_script.pl

use strict;
use warnings;
use Storable qw ( thaw );
use Data::Dumper;
use MIME::Base64;

# should read the imported hash correctly and print it out
my ($imported_scalar) = @ARGV; 
print $imported_scalar;
my %param =  %{ thaw (decode_base64 $imported_scalar ) };
print $param{'fish'};
print "\n";

我怎样才能做到这一点?任何帮助将不胜感激。

谢谢!

【问题讨论】:

  • 你试过这个方法有用吗?你得到了什么错误?
  • 没有返回哈希值,只是对哈希值的引用。
  • 我查看了 .out 文件,上面写着:# LSBATCH: User input perl some_other_script.pl BAcIMTIzNDU2NzgECAgIAwIAAAAKBXBlYXJzBgAAAGFwcGxlcwoFcGFzdGUEAAAAZmlzaA==

标签: perl system lsf


【解决方案1】:

这确实是一个关于bsub 的问题,而不是perl。通过 Base64 编码参数传递参数可能会奏效,但实际上如果您的目的是将数据传递到批处理系统,则可能值得使用输入文件:

如果您查看 bsub 联机帮助页,您会看到:

-i 输入文件 | -is 输入文件

这可能是将“输入”传递给批处理作业的更好方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-07
    • 1970-01-01
    • 2013-09-27
    • 1970-01-01
    • 2015-10-25
    • 1970-01-01
    相关资源
    最近更新 更多