5 Replies Latest reply on Jan 29, 2013 9:28 AM by Michael Meyers

    How to add an external command from a local file?

      My BladeLogic version: 8.1

       

      I'm reading the documentation on the BlPackage : addExternalCmdToStart command.  In the example, it shows adding a command from a local file like this:

       

      RESULT=`blcli BlPackage addExternalCmdToStart $PACKAGE_DBKEY sampleExternalCmd /c/temp/cmd.txt /c/temp/undocmd.txt "Abort"`

       

       

      This command isn't working for me.  It says that the file is not found.  Here's my script:

       

      cat prepare.txt
      PKG_DB=`blcli BlPackage addExternalCmdToStart $PACKAGE1_DBKEY "remove old directory" $componenttype-prepare.txt "" "Abort" "$SINGLE_USER_MODE" "$REBOOT_MODE" "<0,1,2,3" "4,5,6,10..15" "100..200" "0" "<0,1,2,3" "4,5,6,10..15" "100..200" "0"`
      

       

      When it runs it shows this:

      rm -rf /tmp/dir    <--- this is the contents of prepare.txt, so it can definitely find it
       Command execution failed. File 'prepare.txt' not found2013-01-04 18:44:04,537 [INFO] com.bladelogic.om.infra.cli.CLIMain - Command execut at com.bladelogic.om.infra.model.depot.blpackage.BlPackageServiceRequestHandlerImpl.addExternalCmd_11(BlPackageServiceRequestHandlerImpl.java:63 2013-01-04 18:44:04,539 [INFO] com.bladelogic.om.infra.cli.CLIShutdownThread - Cancelling operation...)l.java:319)ava:57)rImpl.java:153)
      

       

      I tried using the absolute path by storing the result of pwd into a variable and using that in the path to the file, but it had the same result.  The cat command could find the file, but the import couldn't find it.

       

      This command is working fine when I use a remote file.  Am I doing something wrong or is the documentation incorrect showing that it can be used for local files?

        • 1. Re: How to add an external command from a local file?

          I came across this post: https://communities.bmc.com/communities/message/158237#158237 so I tried using the normal windows path C:\dir\prepare.txt, but that didn't work either.  It said, /C/dirprepare.txt not found.  That made me think I needed to use a double slash but that had the same result.

          • 2. Re: How to add an external command from a local file?

            Michael, if it works for remote files, then try the following path format: //localhost/c/dir/prepare.txt. As for local paths, seems like a defect, may be worth filing with Support.

            • 3. Re: How to add an external command from a local file?

              When I tried adding localhost is says:

               

              Could not open the file //localhost/c/dir/prepare.txt: No authorization to access host

               

              I've never filed with support.  I'll look into that though.

              • 4. Re: How to add an external command from a local file?
                Bill Robinson

                he needs an agent and acls setup properly for the //localhost/blah to work.  instead try:

                 

                //@/C/file. 

                 

                there are some commands that take nsh paths, some take local OS style paths - it depends on the particular command.

                • 5. Re: How to add an external command from a local file?

                  No luck with that either.  Here's the command I ran:

                   

                  blcli_execute BlPackage getDBKeyByGroupAndName /DummyFolder TestPackage

                  blcli_storeenv packageKey

                   

                  folder=`pwd`

                  folder=//@$folder

                  echo "ls" > command.sh

                  cat command.sh

                  blcli_execute BlPackage addExternalCmdToStart $packageKey sampleExternalCmd $folder/command.sh "" "Abort"

                   

                  Here's the output:

                  myhostname# folder=`pwd`

                  myhostname# folder=//@$folder

                  myhostname# echo "ls" > command.sh

                  myhostname# cat command.sh

                  ls

                  myhostname# blcli_execute BlPackage addExternalCmdToStart $packageKey sampleExternalCmd $folder/command.sh "" "Abort"

                  Command execution failed. com.bladelogic.om.infra.mfw.util.BlException: Could not open the file //@/c/command.sh: No such file or directory

                  2013-01-29 10:20:34,936 [ERROR] com.bladelogic.om.infra.cli.CLIMain - Command execution failed.

                  com.bladelogic.om.infra.mfw.util.BlException: Could not open the file //@/c/command.sh: No such file or directory

                          at com.bladelogic.om.infra.shared.file.FileUtil.getFileContents(FileUtil.java:295)

                          at com.bladelogic.om.infra.shared.file.FileUtil.getFileContents(FileUtil.java:186)

                          at com.bladelogic.om.infra.model.depot.blpackage.BlPackageServiceImpl.addExternalCmd(BlPackageServiceImpl.java:1294)

                          at com.bladelogic.om.infra.model.depot.blpackage.BlPackageServiceRequestHandlerImpl.addExternalCmd_11(BlPackageServiceRequestHandlerImpl.java:630)

                          at com.bladelogic.om.infra.model.depot.blpackage.BlPackageServiceRequestHandlerImpl.execute(BlPackageServiceRequestHandlerImpl.java:153)

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

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

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

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

                          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:101)

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

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

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

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

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

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

                   

                  I've spoken with support and it appears that this command is running in the context of the app server, not my machine.  The raised a defect for this issue. RFE QM001779702