title: IBM i OS/400 QSH - shell script
body: <p>I've got a startup/stop script provided for Tivoli Workload Scheduler in which it will start/stp[ the TWS services in IBM i.</p>
  
  <pre><code>    # CHECK ROOT USER
      WHO=`id | cut -f1 -d" "`
      if [ "$WHO" = "uid=0(root)" ]
      then
      su TWSSVC -c "/etc/rc.d/init.d/tebctl-tws_cpa_agent_TWSSVC stop"
      exit $?
      fi
  
      /etc/rc.d/init.d/tebctl-tws_cpa_agent_TWSSVC stop
      exit $?
  </code></pre>
  
  <p>Problem with this is that, in OS/400 the equivalent of root is QSECOFR, so I've amended the line </p>
  
  <pre><code> if [ "$WHO" = "uid=0(root)" ]
  </code></pre>
  
  <p>to</p>
  
  <pre><code> if [ "$WHO" = "uid=0(QSECOFR)" ]
  </code></pre>
  
  <p>then i got an error on the following line:</p>
  
  <pre><code> su TWSSVC -c "/etc/rc.d/init.d/tebctl-tws_cpa_agent_TWSSVC stop"
  
   /TWSSVC/TWS/ShutDownLwa: 001-0019 Error found searching for command su. No such path or directory.   
  </code></pre>
  
  <p>How do I change to script such that, when it is QSECOFR, it will su into TWSSVC and trigger the start/stop script? I'm not very familiar with OS400. I'm triggering this script in qsh environment.</p>