5 Replies Latest reply on Oct 11, 2012 7:05 AM by tcendrowski

    Find JBoss installation

    tcendrowski

      Hi.

       

      I am writing bash script which needs to find out where jboss is installed. How to find JBoss when JBOSS_HOME is not set, but server is running? Script is transferred to random directory at machine with JBoss and then it has to find JBoss installation and then make som actions. The second thing is that jmx-console is not available on this server and won't be.

       

      Greets.

        • 1. Re: Find JBoss installation
          erasmomarciano

          You can try

           

           

          PID=$(ps -efax | grep java | grep $USERNAME | grep jboss | grep -v grep | awk '{print $2" "$3}' | wc -l)

          • 2. Re: Find JBoss installation
            tcendrowski

            Your code gives me warning:

             

            Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html

            (PID=0)

             

            When I run it without dash after 'ps', command executes, but result in PID is also 0.

            • 3. Re: Find JBoss installation
              peterj

              Have you tried running the command one piece at a time and seeing what the outcome is? In other words, run this:

               

              ps efax | grep java

               

              Make sure you get some output (at least one java process should be available). Then run:

               

              ps efax | grep java | grep $USERNAME

               

              (I suspect that this will yield no output because it assumes that JBoss AS is running under the same user name as the script, which is a bad assumption. Perhaps take that grep out of the command string.)

               

              And then add the next part and so on. Eventually you will have a script that works for you.

              • 4. Re: Find JBoss installation
                erasmomarciano

                Hi

                 

                The warning

                 

                 

                Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html

                (PID=0)

                 

                You can delele "-"  

                 

                Then from ps -efax | grep java to ps efax | grep java

                 

                 

                The meaning of

                 

                $USERNAME = you have to put the user that running Jboss

                 


                 


                • 5. Re: Find JBoss installation
                  tcendrowski

                  Thanks for answers. I made it this way:

                   

                  JBOSS_HOME=$(ps efax | grep "JBOSS_HOME" | grep java | sed "2,1000d" | sed 's/.*JBOSS_HOME=//' | sed 's/services\/jboss .*/services\/jboss/')

                   

                  In my working environment JBOSS_HOME always ends with '/services/jboss' so I am cutting everything after that and everything from beggining of listing to 'JBOSS_HOME=' text. Those things are made by sed. sed "2,1000d" takes only first listing if more than one were found.

                   

                  Greets.