-
1. Re: Find JBoss installation
erasmomarciano Oct 9, 2012 10:47 AM (in response to tcendrowski)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 Oct 9, 2012 11:07 AM (in response to erasmomarciano)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 Oct 9, 2012 12:21 PM (in response to tcendrowski)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 Oct 10, 2012 5:20 AM (in response to tcendrowski)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 Oct 11, 2012 7:05 AM (in response to erasmomarciano)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.