title: Jenkins - Publish Over SSH - EXEC: STDOUT/STDERR - bash: service: command not found
body: <p>I have issue with Publish Over SSH plugin and already try so many possible solution, but still doesn't work:</p>
  
  <ol>
  <li>using exec in pty</li>
  <li>using bash --login</li>
  <li>using shebang (#!/usr/bin/env bash)</li>
  </ol>
  
  <p><strong>Exec Script</strong></p>
  
  <pre><code>service monitoring-daemon stop
  cd /home/push/monitoring/target
  rm -rf Monitoring.jar
  ls -la | grep Monitoring | grep -v grep | awk '{print $9}' | xargs -I file mv file Monitoring.jar
  service monitoring-daemon start
  </code></pre>
  
  <p><strong>Console Output</strong></p>
  
  <pre><code>    10:26:25 SSH: EXEC: STDOUT/STDERR from command [service monitoring-daemon stop
      10:26:25 cd /home/push/monitoring/target
      10:26:25 rm -rf Monitoring.jar
      10:26:25 ls -la | grep Monitoring | grep -v grep | awk '{print $9}' | xargs -I file mv file Monitoring.jar
      10:26:25 service monitoring-daemon start] ...
      10:26:25 SSH: EXEC: connected
      10:26:25 bash: service: command not found
      10:26:25 bash: line 4: service: command not found
      10:26:25 SSH: EXEC: completed after 201 ms
      10:26:25 SSH: Disconnecting configuration [*********] ...
      10:26:25 ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [127]]
      10:26:25 Build step 'Send files or execute commands over SSH' changed build result to UNSTABLE
      10:26:25 [ANALYSIS-COLLECTOR] Computing warning deltas based on reference build #48
  </code></pre>
  
  <p>My Jenkins is using bash as default shell, and remote server also bash.</p>
  
  <p><strong>Remote Server .bashrc</strong></p>
  
  <pre><code># .bashrc
  alias service='/sbin/service'
  # Source global definitions
  if [ -f /etc/bashrc ]; then
          . /etc/bashrc
  fi
  
  # User specific aliases and functions
  </code></pre>
  
  <p><strong>Remote Server .bash_profile</strong></p>
  
  <pre><code># .bash_profile
  # Get the aliases and functions
  if [ -f ~/.bashrc ]; then
          . ~/.bashrc
  fi
  
  # User specific environment and startup programs
  
  PATH=$PATH:$HOME/bin
  export PATH
  </code></pre>
  
  <p>is there any piece of configuration or step that I'm missing?</p>