I am writing some small shell script utility which automates deployment process. I ready many links related to command for shutting down the jboss server in linux so that I can shutdown the server from my utility.

Read some links which will tell how to do it in jboss 7 or later but not in old jboss versions like 5.x. One such is 

```
 "$JBOSS_HOME/bin/jboss-cli.sh" --connect command=:shutdown 

```

I want to shutdown the jboss 5.2 version from my shell script? 

Edit: Jboss 5 version has shutdown.sh in the bin folder. But I am getting the below exception when I say

```
sh shutdown.sh -S

[john@mymachine bin]$ sh shutdown.sh  -S
Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused]]]
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1851)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:720)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:713)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at org.jboss.Shutdown.main(Shutdown.java:225)
Caused by: javax.naming.CommunicationException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused]]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:362)
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:287)
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1821)
    ... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:332)
    ... 6 more
Caused by: java.net.ConnectException: Connection refused

```

Any idea ??

Regards