Hi would like to pass a parameter to my perl script that should be executed trough qsub. So I run:
qsub -l nodes=node01 -v "i=500" Test.pl
While in Test.pl I try to call i parameter in several way:
use Getopt::Long;
$result = GetOptions ("i" => \$num);
open(FILE,">/data/home/FILEout.txt");
print FILE "$num\n";
print FILE "$ARGV[0]";
close(FILE);
Unfortunatelly output file of the perl script is always empty.
Do you have any suggestions? Where I'm wrong? Help please
Test.pl
:use Data::Dumper; open($FH,">/data/home/FILEout.txt") or die $!; local $Data::Dumper::Terse=1; local $Data::Dumper::Indent=0; print($FH Dumper(\@ARGV), "\n"); print($FH join(',', keys(%ENV)), "\n");
?PBS_NODEFILE,PBS_O_SHELL,PBS_O_SYSTEM,SSH_ASKPASS,PBS_O_WORKDIR,PBS_O_LANG,PBS_O_MAIL,PBS_O_PATH,LESSOPEN,PBS_JOBCOOKIE,PWD,LANG,USER,PBS_O_HOST,G_BROKEN_FILENAMES,LOGNAME,PBS_JOBID,SHLVL,INPUTRC,PATH,PBS_ENVIRONMENT,PBS_O_QUEUE,OMP_NUM_THREADS,PBS_QUEUE,HISTSIZE,PBS_O_HOME,PBS_MOMPORT,HOME,MAIL,PBS_O_LOGNAME,TZ,PBS_NODENUM,PBS_TASKNUM,NCPUS,HOSTNAME,_,LS_COLORS,SHELL,PBS_JOBNAME,PBS_JOBDIR,TMPDIR,ENVIRONMENT
using the commandqsub -l nodes=node01 -v "i=500" Test.pl
#!/bin/sh if [ "x" == "x$MYVAR" ] ; then echo "Variable is not set" else echo "Variable says: $MYVAR" fi
in yourqsub
's docs? If so, what happens if you try that (with-v 'MYVAR=500'
)? And what if you change$MYVAR
to$i
(with-v 'i=500'
)?