6 Replies Latest reply on May 30, 2014 2:26 PM by Raja Mohan

    how to capture an error and exit

    Raja Mohan

      Curious, I often notice when a blcli command fails, it throws a java exception and can be seen in the application log through java traces. But the execution job just hangs. How to catch this and exit out of the script? any clean way in NSH script? It will be tedious to check for the various possible results each one of the command will have.

        • 1. Re: how to capture an error and exit
          Bill Robinson

          can you attach the script and indicate where you see it hang ?

          • 2. Re: how to capture an error and exit
            Raja Mohan

            hi Bill,


            doesnt matter where it is. In this case the VGJ job already existed and just hang after the command.


            [30 May 2014 11:14:55,913] [Client-Connections-Thread-1] [ERROR] [user@xxx.com:ENGINEER:10.xx.xx.xx] [Client] <JobName>:VGPSMALL-RHEL6_JOB already exists in JobFolderId:2013000.

            com.bladelogic.om.infra.mfw.util.BlException: <JobName>:VGPSMALL-RHEL6_JOB already exists in JobFolderId:2013000.

                    at com.bladelogic.om.virtualization.model.depot.vgp.VGPPlatformSupportBase.validateVGJConfig(VGPPlatformSupportBase.java:792)

                    at com.bladelogic.om.virtualization.model.depot.vgp.VGPPlatformSupportBase.createVirtualGuest(VGPPlatformSupportBase.java:506)

                    at com.bladelogic.om.virtualization.app.service.VirtualGuestPackageServiceImpl.createVirtualGuest(VirtualGuestPackageServiceImpl.java:869)

                    at com.bladelogic.om.virtualization.app.service.VirtualGuestPackageServiceImpl.createVirtualGuest(VirtualGuestPackageServiceImpl.java:890)

                    at com.bladelogic.om.virtualization.app.service.VirtualGuestPackageServiceRequestHandlerImpl.createVirtualGuest_11(VirtualGuestPackageServiceRequestHandlerImpl.java:787)

                    at com.bladelogic.om.virtualization.app.service.VirtualGuestPackageServiceRequestHandlerImpl.execute(VirtualGuestPackageServiceRequestHandlerImpl.java:337)

                    at com.bladelogic.om.infra.app.api.manage.APIMethodInvocationProvider.executeRequest(APIMethodInvocationProvider.java:54)

                    at com.bladelogic.om.infra.app.api.manage.APIMethodInvocationProvider.invoke(APIMethodInvocationProvider.java:39)

                    at com.bladelogic.om.infra.app.service.routing.RoutingServiceImpl.invokeMethodLocally(RoutingServiceImpl.java:317)

                    at com.bladelogic.om.infra.app.service.routing.RoutingServiceImpl.invoke(RoutingServiceImpl.java:244)

                    at com.bladelogic.om.infra.app.api.manage.APIRequestManager.executeRequest(APIRequestManager.java:30)

                    at com.bladelogic.om.infra.message.app.frame.APIMessageFrame.service(APIMessageFrame.java:113)

                    at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.processRequest(ClientWorkerThread.java:385)

                    at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.processClientRequest(ClientWorkerThread.java:282)

                    at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.handleClientRequest(ClientWorkerThread.java:182)

                    at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.execute(ClientWorkerThread.java:101)

                    at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.execute(ClientWorkerThread.java:27)

                    at com.bladelogic.om.infra.app.service.thread.BlBlockingThread.run(BlBlockingThread.java:95)

            • 3. Re: how to capture an error and exit
              Bill Robinson

              Why don’t you do a check first to see if the object is there before running the create command ?

              • 4. Re: how to capture an error and exit
                Raja Mohan

                I am for the most part have a check before execute, if the check had failed, it will hang there. That is what i want to capture and exit out. I was only posting it as an example.

                • 5. Re: how to capture an error and exit
                  Bill Robinson

                  an object that already exists should not cause a hang, it would just fail, and the next command should run unless you do something to catch it and exit - eg check the return code.


                  how are you checking to see if the object already exists?  if that check works the create won't run... maybe like 'Job isJobNameExists <groupId> <name> <typeid>' ?

                  • 6. Re: how to capture an error and exit
                    Raja Mohan

                    I think i have fixed the code for most part added an error check for each blcli command


                    if [ $? != 0 ]; then


                    echo "blcli command Failed to xxxxx"




                    exit 99



                    I have opened a support ticket as well.