title: Get return code and status from bash script into Java file
body: <p>I am working in JavaFX scene builder App where at some point my code flow execution is like below:</p>
  
  <p>From my Java class a bash script script1 called
  From <code>MyClass.java</code> </p>
  
  <pre><code>exec(./Script1)
  </code></pre>
  
  <p>in 
  script1 an another script script2 called</p>
  
  <pre><code>called ./script2
  </code></pre>
  
  <p>script2 an another script script3 called</p>
  
  <p>In
  script3</p>
  
  <pre><code>if [ ! "$upgrade_file_path" = "" ]; then
      echo "BUILD SUCCESS"
      echo "upgrade.cpio.gz : "$upgrade_file_path
      //LINE-1
  else
      echo "FAILED TO CREATE upgrade.cpio.gz"
  fi
  </code></pre>
  
  <p>What I need : </p>
  
  <p>LINE-1 : Can I return some exit code from here to my java file (MyClass.java), I need to show the <strong>BUILD SUCESS</strong> string along with <code>$upgrade_file_path</code> and an exit code in my javafx label. 
  Or I can save this exit code,path and status in a string in my <code>MyClass.java</code> file?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I am using an external jar to connect SSH. What I am trying to do is to connect a linux machine from my windows machine, and to achieve this I have used sshexec.jar <a href="http://see%20this%20llink" rel="nofollow">https://code.google.com/p/sshxcute/downloads/list</a></p>
  
  <p>where below code does the job of connecting and executing the bash script</p>
  
  <pre><code>        ConnBean cb = new ConnBean(buildServerURL, buildServerUsername,buildServerPassword);
          // Put the ConnBean instance as parameter for SSHExec static method getInstance(ConnBean) to retrieve a singleton SSHExec instance
          ssh = SSHExec.getInstance(cb);          
          //Connect to server
          ssh.connect();
          CustomTask sampleTask = new ExecCommand("/usr/init/checkout.sh");
          //Execution of main taks
          Result rs = ssh.exec(sampleTask);
  </code></pre>