title: Using parameters from BASH file name as arguments for Julia script on cluster
body: <p>This is an extension of a previous question I asked:</p>
  <p><a href="https://stackoverflow.com/questions/65742185/using-name-of-bash-script-as-input-argument">Using name of BASH script as input argument</a></p>
  <p>My goal is to write a BASH script which takes the arguments from the file's name and uses them as inputs for a Julia code I'm writing, and then submit the BASH script to a remote cluster. Using @AndriyMakukha's solution, I was able to write the following script through Torque:</p>
  <pre><code>#!/bin/bash
   
  #PBS -l mem=10gb,nodes=1:ppn=2,walltime=1:00:00
  #PBS -N ES_100_20_100
  #PBS -j oe
  #PBS -o ./log/julia.${PBS_JOBID}.out
  
  module load julia/1.5.1 python/3.8.1
   
  PARAM1=$( echo ${0%%.pbs} | awk -F &quot;_&quot; '{print $2}' )  
  PARAM2=$( echo ${0%%.pbs} | awk -F &quot;_&quot; '{print $3}' )  
  PARAM3=$( echo ${0%%.pbs} | awk -F &quot;_&quot; '{print $4}' )  
  PARAM4=$( echo ${0%%.pbs} | awk -F &quot;_&quot; '{print $5}' ) 
  PARAM5=$( echo ${0%%.pbs} | awk -F &quot;_&quot; '{print $6}' )  
   
  echo &quot;Param 1: $PARAM1&quot;
  echo &quot;Param 2: $PARAM2&quot;
  echo &quot;Param 3: $PARAM3&quot;
  echo &quot;Param 4: $PARAM4&quot;
  echo &quot;Param 5: $PARAM5&quot;
  
  cd path/to/code 
  julia Example.jl $PARAM1 $PARAM1 $PARAM2 $PARAM3 $PARAM4 $PARAM5 
  </code></pre>
  <p>This script (called &quot;Example_1_2_3_4_5.pbs&quot;) prints the different parameters from the filename to the output file, and then runs the Julia code with said parameters as the ARGS. When I run this on the local machine, it works great. When I submit the code to the cluster via qsub, I get the following error in the output file:</p>
  <pre><code>Param 1: priv/jobs/3574314-1.orion.cm.cluster.SC
  Param 2:
  Param 3:
  Param 4:
  Param 5:
  ERROR: LoadError: ArgumentError: invalid base 10 digit 'p' in &quot;priv/jobs/3574314-1.cluster_name.cm.cluster.SC&quot;
  </code></pre>
  <p>Obviously, the code isn't reading the parameters correctly; i.e., it returns the name of the job, not the name of the BASH file itself. This is obvious because</p>
  <pre><code>echo ${0%%.pbs}
  </code></pre>
  <p>returns</p>
  <pre><code>/cm/local/apps/torque/var/spool/mom_priv/jobs/3574314-1.orion.cm.cluster.SC
  </code></pre>
  <p>How can I get the name of the pbs file itself if I submit to cluster, seeing as ${0%%.pbs} doesn't work?</p>