title: How to change working directory on slurum
body: <p>I am working on a slurm cluster where I am running couple of jobs. It is hard for me to check the jobs one by one in each directory.</p>
  <p>I could manage to check in which directory the jobs are running using</p>
  <pre><code>scontrol show job JOB_ID
  </code></pre>
  <p>This command gives me various lines on the output. Few of them are listed below</p>
  <pre><code>   OverSubscribe=OK Contiguous=0 Licenses=(null) Network=(null)
     Command=/home/astha/vt-st/scf-test/303030/49/qsub.job
     WorkDir=/home/astha/vt-st/scf-test/303030/49
     StdErr=/home/astha/vt-st/scf-test/303030/49/qsub.job.e1205
     StdIn=/dev/null
     StdOut=/home/astha/vt-st/scf-test/303030/49/qsub.job.o1205
     Power=
     MailUser=(null) MailType=NONE
  </code></pre>
  <p>Where WorkDir (this is an example, the path will be different for each job) from above output is the directory in which I want to switch.</p>
  <p>then</p>
  <pre><code>cd /home/astha/vt-st/scf-test/303030/49
  </code></pre>
  <p>But typing this long commands make my fingers cry.</p>
  <p>I have tried to make a small python script to print scontrol show job</p>
  <pre><code># Try block
  try:
      # Take a number
          print(&quot;scontrol show job&quot;)
  
  
  # Exception block
  except (ValueError):
    # Print error message
    print(&quot;Enter a numeric value&quot;)
  </code></pre>
  <p>But then how I should improve it so that it takes my given input number and then grep the WorkDir from the output and change the directory.</p>
  <p>Thank you very much.</p>