0 Replies Latest reply: Jun 7, 2011 5:40 AM by 793848 RSS

    Shellscript doesn't return result of commands and doesn't start ext service

    793848
      Hi
      I revoke shell script via java stored procedure. The script need to start OpenOffice service.
      Here is it:
      #!/usr/bin/bash
      OFFICE_DIR='/opt/openoffice.org2.4/program'
      JAVA_DIR='/usr/jdk/instances/jdk1.6.0'
      echo "START"
      
      ls     ## no result
      ps    ## no result
      pgrep   ## no result
      
      SERVICE='soffice.bin'
      if pgrep $SERVICE > /dev/null
      then
          echo "$SERVICE service running"
      else
          echo "$SERVICE is not running"
          echo "Start $SERVICE" 
          $OFFICE_DIR/soffice -invisible -headless -nofirststartwizard "-accept=socket,host=localhost,port=8100;urp" &   # it doesnt work
          echo "$SERVICE started" 
      fi
      
      #$JAVA_DIR/jre/bin/java  -classpath "odtreports.jar:lib/commons-io-1.4.jar:lib/commons-cli-1.2.jar:lib/odfdom-java-0.8.7.jar:lib/xercesImpl.jar:lib/juh.jar:lib/ridl.jar:lib/unoil.jar:lib/bootstrapconnector.jar:/opt/openoffice.org2.4/program" ru.infonetsoft.reporter.OdtReporter 
      I check if the service is started already (pgrep $SERVICE > /dev/null).
      When the script is running directly from OS environment all work fine. But if i try it from OJVM, pgrep always return null. I test with ps and ls, but result is null, as well.
      Soffice service doesnt start. But echo command always work printing string. It seems that script ruuning at an environment isolated from OS.

      Java stored procedure:
      private static void runCmd(String blankPath, String xmlPath, boolean makePdf)    throws IOException
        {
          List<String> command = new ArrayList<String>();
          
          command.add("bash");
      
          command.add("./makereport.bsh");  // script
      
         System.out.println("START");
          ProcessBuilder builder = new ProcessBuilder(command);
          builder.directory(new File("/home/ora11/odt_generator"));  // path the script is located
          final Process process = builder.start();
          InputStream is = process.getInputStream();
          InputStreamReader isr = new InputStreamReader(is);
          BufferedReader br = new BufferedReader(isr);
          String line;
          while ((line = br.readLine()) != null) {
            System.out.println(line);
          }
          System.out.println("Program terminated!");
        }
      Result of executing looks like that
      START
       
      soffice.bin is not running
      Start soffice.bin
      soffice.bin started
      Program terminated!
      Actually service doesnt start.


      Granted permissions:
      GRANT      BOB      SYS      java.io.FilePermission      <<ALL FILES>>      read,write,delete,execute      ENABLED
      GRANT      BOB      SYS      java.lang.RuntimePermission      getClassLoader           ENABLED
      GRANT      BOB      SYS      java.lang.RuntimePermission      getClassLoader           ENABLED
      GRANT      BOB      SYS      java.lang.RuntimePermission      getClassLoader           ENABLED
      GRANT      BOB      SYS      java.lang.RuntimePermission      readFileDescriptor           ENABLED
      GRANT      BOB      SYS      java.lang.RuntimePermission      writeFileDescriptor           ENABLED
      GRANT      BOB      SYS      java.net.SocketPermission      *      connect,resolve      ENABLED

      Solaris 9, Oracle 11g

      Any suggestions?

      --Anton

      Edited by: 790845 on 07.06.2011 3:39