【问题标题】:qsub: how to pass argument to perl script called within a shell scriptqsub:如何将参数传递给在 shell 脚本中调用的 perl 脚本
【发布时间】:2015-11-12 19:52:56
【问题描述】:

这是 cwd 中的内容:

blastn_build.sh qscript

它们当前都设置为可执行(但不是二进制)

这是blastn_build.sh的内容:

#!/bin/bash
update_blastdb.pl --showall

下面是qscript的内容:

qsub -S /bin/bash -V -b n -N nt_wgs_build -pe smp 8 -j y  -o ./nt_wgs_build.sge -l h=n10 -cwd -sync y "./blastn_build.sh"

update_blastdb.pl 在我的 PATH 中并以 #!/usr/bin/perl 开头


现在的问题:

运行 ./blastn_build.sh 按预期工作。 运行 ./qscript 不会...这是错误消息:

无法连接到 ftp.ncbi.nlm.nih.gov:参数无效

如果我从 ./blastn_build.sh 中删除 --showall 参数,那么 ./blastn_build.sh 和 ./qscript 都会按预期工作。问题似乎在于如何通过 qsub 正确地将 --showall 选项传递给 update_blastdb.pl。

任何帮助理解和修复将不胜感激!

update_blastdb.pl (blast-2.2.31 http://www.ncbi.nlm.nih.gov/books/NBK52640/) wgetftp://ftp.ncbi.nlm.nih.gov/blast/executables/LATEST/ncbi-blast-2.2.31+-x64-linux.tar.gz

#!/usr/bin/perl
# $Id: update_blastdb.pl 446090 2014-09-11 12:12:27Z ivanov $
===========================================================================
#
# Author:  Christiam Camacho
#
# File Description:
#   Script to download the pre-formatted BLAST databases from the NCBI ftp
#   server.
#
#        

use strict;
use warnings;
use Net::FTP;
use Getopt::Long;
use Pod::Usage;
use File::stat;
use Digest::MD5;
use Archive::Tar;
use List::MoreUtils qw(uniq);

use constant NCBI_FTP => "ftp.ncbi.nlm.nih.gov";
use constant BLAST_DB_DIR => "/blast/db";
use constant USER => "anonymous";
use constant PASSWORD => "anonymous";
use constant DEBUG => 0;
use constant MAX_DOWNLOAD_ATTEMPTS => 3;
use constant EXIT_FAILURE => 2;

# Process command line options
my $opt_verbose = 1;
my $opt_quiet = 0;
my $opt_force_download = 0;
my $opt_help = 0;
my $opt_passive = 0;
my $opt_timeout = 120;
my $opt_showall = 0;
my $opt_show_version = 0;
my $opt_decompress = 0;
my $result = GetOptions("verbose+"      =>  \$opt_verbose,
                    "quiet"         =>  \$opt_quiet,
                    "force"         =>  \$opt_force_download,
                    "passive"       =>  \$opt_passive,
                    "timeout=i"     =>  \$opt_timeout,
                    "showall"       =>  \$opt_showall,
                    "version"       =>  \$opt_show_version,
                    "decompress"    =>  \$opt_decompress,
                    "help"          =>  \$opt_help);
$opt_verbose = 0 if $opt_quiet;
die "Failed to parse command line options\n" unless $result;
pod2usage({-exitval => 0, -verbose => 2}) if $opt_help;
pod2usage({-exitval => 0, -verbose => 2}) unless (scalar @ARGV or
                                              $opt_showall or
                                              $opt_show_version);
#rest of code continues...

perl v 5.10.1

【问题讨论】:

  • 如果不知道update_blastdb.pl 做了什么,就无法回答。闻起来像版本问题 - 你确定 ./blastn_build.sh 正确传递给 qsub 吗?这是一个相对路径,所以你可能有路径遍历。
  • @Sobrique -- 我刚刚尝试更改 qscript 以引用完整路径:“/home/10019438/blastdb/2015_11_11/blastn_build.sh”但错误仍然存​​在。
  • 如果从命令行运行./update_blastdb.pl < /dev/null 会发生什么?你得到错误了吗?
  • @Jonathan Leffler -- 这给出了这个错误:stty: standard input: Inappropriate ioctl for device
  • 那么看来,update_blastdb.pl 确实不是为了在终端上运行而设计的——原因我不知道。根据调用方式的不同,它会做不同的事情。 qsub 系统可能在没有终端连接的情况下运行它,这就是为什么 < /dev/null 测试很有趣。 '我很好奇是 stty 报告了错误——我想知道它是怎么回事,但我没有足够的好奇心下载找出答案。不清楚为什么 Perl 在从 qsub 运行而不是从终端运行时无法连接;网络不应该受到影响。

标签: linux perl qsub


【解决方案1】:

看起来您实际上是在某个集群环境中工作(或者 qsub 是什么?)。在这样的地方,你的 qsubed 脚本实际上运行在不同的节点上,这些节点可能没有互联网连接,可以从不同的目录开始执行你的脚本,或者可能有许多其他来自旅游原始主机的错误配置......

【讨论】:

  • 你完全正确。非常感谢所有帮助我解决问题的人。现在事情进展顺利。
猜你喜欢
  • 1970-01-01
  • 2012-12-08
  • 1970-01-01
  • 1970-01-01
  • 2015-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多