简体   繁体   中英

qsub: how to pass argument to perl script called within a shell script

Here is what is in the cwd:

blastn_build.sh qscript

They are both currently set to executable (but not binary)

Here are the contents of blastn_build.sh:

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

Here are the contents of 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 is in my PATH and begins with #!/usr/bin/perl


Now the problem:

Running ./blastn_build.sh works as expected. Running ./qscript does not... here is the error message:

Failed to connect to ftp.ncbi.nlm.nih.gov: Invalid argument

If I remove the --showall argument from ./blastn_build.sh then BOTH ./blastn_build.sh AND ./qscript work as expected. The issue seems to be in how to correctly pass the --showall option to update_blastdb.pl through qsub.

Any help understand and fixing would be much appreciated!

update_blastdb.pl (blast-2.2.31 http://www.ncbi.nlm.nih.gov/books/NBK52640/ ) wget ftp://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

Looks like you are actually working in some cluster environment (or what else is qsub?). In such place your qsubed script actually runs on different node, which can have no internet connection, can execute your script starting from different directory, or can have many other misconfigures from tour original host...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM