1 2 Previous Next 20 Replies Latest reply on Jan 4, 2017 2:00 PM by Dale Reagan Branched from an earlier discussion.

    blcli redirection fails in 8.9

    Dale Reagan

      Just tested a script that uses 'enhanced' commands; it's been working fine since ~8.3.

      In out test 8.9 environment fails w/no error indication... (function simply returns from that point)

      Fix - revert to non-enhanced (i.e. 'blcli ' vs 'blcli_execute').

       

       

      Dale

        • 1. Re: blcli redirection fails in 8.9
          Bill Robinson

          Just tested a script that uses 'enhanced' commands; it's been working fine since ~8.3.

          -> which ones ?

           

          In out test 8.9 environment fails w/no error indication... (function simply returns from that point)

          -> can you provide the function and job run log?  have you looked in the appserver logs to see if there are any errors ?

           

           

          Fix - revert to non-enhanced (i.e. 'blcli ' vs 'blcli_execute').

          -> can you instead disable the blcli server and use go back to using the ‘performance commands’ and see if there is still a problem ?

          • 2. Re: blcli redirection fails in 8.9
            Dale Reagan

            Same 'sandbox' as Al He already disabled/restarted.

            No errors in APP log...

            Trying a 'simplified' script - could be I'm missing something...

             

             

            Dale

            • 3. Re: blcli redirection fails in 8.9
              Dale Reagan

              OK, seems resolved after I exited ALL NSH sessions, deleted creds and re-authenticated.

              But... still testing...

               

               

              Dale

              • 4. Re: blcli redirection fails in 8.9
                Bill Robinson

                The ‘blcli server’ is only ever used by nsh script jobs.  should have nothing to do at all w/ any interactive sessions.

                • 5. Re: blcli redirection fails in 8.9
                  Dale Reagan

                  OKOK, seems that there is a 'feature' here. If you redirect output AND use enhanced commands in 8.9 then the command fails without any error message.

                  This seems to be working with 8.6 - perhaps a known issues (seems I recall some previous quirks about re-direction...)

                   

                  ###
                  function check_add_server {
                  printf "## Checking to see if ${SYS} is in the BL DB: "
                  blcli_execute Server printPropertyValue  ${SYS} OS_PLATFORM
                  echo " ##"
                  }
                  ###
                  SCMD=$(basename $0)
                  LOG=${SCMD}.log

                  blcli_connect
                  case $1
                  in
                          log) SYS=$2 ; check_add_server  | tee ${LOG} ;; ## this fails
                            *) SYS=$1 ;  check_add_server  ;;  ## this works
                  esac
                  #       check_add_server 2>&1  | tee ${LOG}
                  blcli_disconnect
                  echo "## end ##"

                  • 6. Re: blcli redirection fails in 8.9
                    Bill Robinson

                    "OKOK, seems that there is a 'feature' here. If you redirect output AND use enhanced commands in 8.9 then the command fails without any error message.?"

                     

                     

                    this is from a nsh job or a script you are running from the command line ?

                    • 7. Re: blcli redirection fails in 8.9
                      Dale Reagan

                      This is a command line script.

                      • 8. Re: blcli redirection fails in 8.9
                        Bill Robinson

                        ok - this has nothing to do w/ the blcli server problem then.

                         

                         

                        if you don't want to see the stdout from the blcli_execute command set this option:

                         

                        blcli_setjvmoption -Dcom.bladelogic.cli.execute.quietmode.enabled=true?

                         

                        https://docs.bmc.com/docs/ServerAutomation/86/developing/blcli-reference/nsh-performance-commands

                        • 9. Re: blcli redirection fails in 8.9
                          Dale Reagan

                          Sorry, you are correct - a separate, but related issue - blcli command 'fails' under scenario as shown; Reasonable confidence that it would also fail via Console job; points are:

                           

                          1. perhaps this should be it's own thread?
                          2. that output redirection is not-what-I-would-expect, AND,
                          3. the behavior (the handling of output redirection) of blcli_execute appears to be different between 8.6 and 8.9.
                          4. flipping the flag ( blcli_setoption outputRedirectingDisabled true/false) does not seem to make a difference (for me)

                           

                          Not a biggie for now - still exploring the diffs w/8.9...

                           

                           

                          Dale

                          • 10. Re: blcli redirection fails in 8.9
                            Bill Robinson

                            1 - done

                            2 - there have been issues w/ the redirection for a while which is why we have the blcli_storeenv/storelocal to store command results as variables and the quitemode parameter to stop stdout from showing on the console.

                            3 - perhaps

                            4 - blcli_setjvmoption - which must be run before any other blcli_xxx commands including blcli_connect, blcli_setoption. 

                            • 11. Re: blcli redirection fails in 8.9
                              Dale Reagan

                              Super, thanks!  I will give that  a whirl (tomorrow...)

                               

                               

                              Dale

                              • 12. Re: blcli redirection fails in 8.9
                                Dale Reagan

                                Ok, 'option' setting does turn 'off' the output from the blcli_execute commands, however, that does NOT resolve the redirection issue.

                                 

                                My guess is that blcli base code was modified such that STDIO (standard IO) pointers have been change to values not compatible with NSH or otherwise changed in such a manner as to BREAK shell level re-direction.   This is bad (IMO) since the change moves away from the extremely useful Everything_is_a_file convention (i.e. Unix-style I/O) to a  new BMC/other-standard way of doing things.

                                 

                                Such a change suggests to me that the approvers of these changes did not understand the implications for the product functionality.

                                 

                                If your NSH scripts are written with sequential steps ('strait through', no functions or attempts to redirect blcli_execute output) then you should be ok; however, if you use functions that make use of Blcli-enhanced commands and also use redirection to capture output from functions then your functions/scripts will 'break' without any error indication.

                                • 13. Re: blcli redirection fails in 8.9
                                  Bill Robinson

                                  why are you trying to use redirection?    what is the issue w/ using the blcli_storeenv/storelocal to capture the blcli command output ?

                                  • 14. Re: blcli redirection fails in 8.9
                                    Dale Reagan
                                    1. no problem w/capturing output via blcli_storeenv - works as expected
                                    2. the issue (for me) is that 'standard file descriptors' (i.e. as in 'C' code using STDIO/STDOUT/STDERR) are being 'mucked with' such that the expected program output has changed; this 'enhancement' has 'broken' ~30 NSH scripts, which I must now re-rewrite; as much as I enjoy working I would prefer to be creating new solutions instead of having to craft work-arounds for changes between BSA versions...
                                    3. the Why? - could be that I am all alone here (coding style); makes more sense to me to have one 'output statement' vs one per each output instance; I tend to wrap things up in one function and redirect all output from the function (simple, quick, easy...)

                                     

                                     

                                    Dale

                                    1 2 Previous Next