title: Shell script to Sudo in Remote Machine and execute commands
body: <pre><code>#!/bin/csh
  ssh -o StrictHostKeyChecking=no xyz123@remotemachine.com
  sudo -su rootuser
  ksh
  . /mydir/setup_env.ksh
  ls -ltr
  </code></pre>
  
  <p>Above is the list of task i  need to do. </p>
  
  <ol>
  <li>Login into remote machine without password prompt</li>
  <li>Run Sudo to get access to Root</li>
  <li>Change shell to ksh</li>
  <li>execute a script (setup_env.ksh)</li>
  <li>List files using ls -ltr</li>
  </ol>
  
  <p>When i execute this script from , lets say localunixmachine.com...</p>
  
  <ol>
  <li>It ask me for password</li>
  <li>once i enter password , it will transfer to remote machine but wont execute remaining commands</li>
  <li>If i exit from remote session, it will execute remaining command.</li>
  </ol>
  
  <p>Can you please Guide me whats the best way to accomplish what i am trying here.</p>