Perl code unable to write files after run via pbs


#1

I am trying to test the file write action of this perl code run via pbs.

#!/usr/bin/perl
open(FOUT,">$file".".txt");
for $i(0..100){
	print FOUT "$i\n";
}
close FOUT;

I am calling this code by simply.

#!/bin/csh
#PBS -l walltime=10:00:00
#PBS -N hello_world1
#PBS -q workq
#PBS -l select=4:ncpus=16:mpiprocs=16
#PBS -l place=scatter:excl
#PBS -V
module load perl-5.16.3
echo PBS working directory is $PBS_O_WORKDIR
perl $PBS_O_WORKDIR/code.pl
perl --version

The output can be printed to pbs outfile but the file can not be created through perl via pbs.
What may be the issue?
Note: No errors in pbs log.


#2

Please try the below:

[root@opencent ~]# ls -ltr *.pl
-rwxr-xr-x 1 root root 119 Sep 24 13:28 test.pl


   [root@opencent ~]# cat test.pl
        #!/usr/bin/perl
        my $filename="code";
        open(FOUT,">$filename".".txt");
        for $i(0..100){
        	print FOUT "$i\n";
        }
        close FOUT;

[root@opencent ~]# qsub -l select=1:ncpus=1 -l walltime=00:10:00 -N HELLOWORLD -q workq -l place=scatter:excl -- /usr/bin/perl ./test.pl
11780.opencent

[root@opencent ~]# ls -ltr code.txt
-rw------- 1 root root 294 Sep 24 13:34 code.txt


#3

Thanks @adarsh . I do not have root privileges. I tried your qsub command. Job is submitted. but the file that was supposed to be formed did not form and no errors were found.
My

> ls -ltr x.pl

showed:
> -rwxrwxrwx 1 user cluster 175 Sep 25 12:09 x.pl


#4

[pbsdata@opencent ~]$ pwd
/home/pbsdata

[pbsdata@opencent ~]$ ls -ltr
total 4
-rwxrwxr-x 1 pbsdata pbsdata 119 Sep 25 08:31 test.pl

[pbsdata@opencent ~]$ qsub -l select=1:ncpus=1 -l walltime=00:10:00 -N HELLOWORLD -q workq -l place=scatter:excl – /usr/bin/perl ./test.pl
11782.opencent

[pbsdata@opencent ~]$ ls -ltr
total 8
-rwxrwxr-x 1 pbsdata pbsdata 119 Sep 25 08:31 test.pl
-rw------- 1 pbsdata pbsdata 0 Sep 25 08:32 HELLOWORLD.o11782
-rw------- 1 pbsdata pbsdata 0 Sep 25 08:32 HELLOWORLD.e11782
-rw------- 1 pbsdata pbsdata 294 Sep 25 08:32 code.txt


#5

Please try and test this:

[pbsdata@opencent ~]$ cat pbs.sh
#!/bin/bash
hostname
date
env

[pbsdata@opencent ~]$ chmod +x pbs.sh

*[pbsdata@opencent ~]$ ls -ltr .sh
-rwxrwxr-x 1 pbsdata pbsdata 31 Sep 25 08:54 pbs.sh

**[pbsdata@opencent ~] qsub -l select=1:ncpus=1 -l walltime=00:10:00 -N HELLOWORLD -q workq -l place=scatter:excl -- pbs.sh** 11785.opencent [pbsdata@opencent ~] ls -ltr | grep 11785
-rw------- 1 pbsdata pbsdata 0 Sep 25 08:54 HELLOWORLD.e11785
-rw------- 1 pbsdata pbsdata 846 Sep 25 08:54 HELLOWORLD.o11785

[pbsdata@opencent ~]$ cat HELLOWORLD.o11785
opencent
Tue Sep 25 08:54:56 BST 2018
SHELL=/bin/bash
TMPDIR=/var/tmp/pbs.11785.opencent
PBS_JOBNAME=HELLOWORLD
PBS_ENVIRONMENT=PBS_BATCH
PBS_O_WORKDIR=/home/pbsdata
NCPUS=1
PBS_TASKNUM=1
USER=pbsdata
PBS_O_HOME=/home/pbsdata
PBS_MOMPORT=15003
PBS_O_QUEUE=workq
PBS_O_LOGNAME=pbsdata
PATH=/bin:/usr/bin
PBS_O_LANG=en_US.UTF-8
PBS_JOBCOOKIE=0000000042FB103400000000708351EC
PWD=/home/pbsdata
PBS_NODENUM=0
PBS_JOBDIR=/home/pbsdata
TZ=Europe/London
PBS_O_SHELL=/bin/bash
PBS_JOBID=11785.opencent
ENVIRONMENT=BATCH
SHLVL=1
HOME=/home/pbsdata
PBS_O_HOST=opencent
LOGNAME=pbsdata
PBS_QUEUE=workq
OMP_NUM_THREADS=1
PBS_O_MAIL=/var/spool/mail/pbsdata
PBS_O_SYSTEM=Linux
PBS_NODEFILE=/var/spool/pbs/aux/11785.opencent
PBS_O_PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/pbs/bin:/home/pbsdata/bin
_=/bin/env