2 Replies Latest reply on Aug 17, 2006 8:27 PM by Justin Suissa

    blquery issues

      I found Tim's blquery script:

      https://www.bladelogic.com/community/entry.jspa?categoryID=29&externalID=79

       

      And was able to get it to work fine from the command line:

       

      PCA02APP910% blquery admin30 -E admin_users.blq

      admin30 = Administrator

       

      However, I can't seem to get it to work when I try running the blquery directly from the command line:

       

      PCA02APP910% blquery -e user_record_count ('

      quote>

      quote> user_type (NAME) = BUA_ADMIN_ACCOUNT

      quote> && ( ! user_disabled (NAME)

      quote> && ( ! user_locked (NAME)

      quote> && printf ("%s - %s\n", HOSTNAME, NAME)));

      quote>

      quote> ');

      nsh: unknown file attribute

       

      Or when I try condensing the query down to one line:

       

      PCA02APP910% blquery -e user_record_count ('user_type (NAME) = BUA_ADMIN_ACCOUNT && ( ! user_disabled (NAME) && ( ! user_locked (NAME) && printf ("%s - %s\n", HOSTNAME, NAME)));');

      nsh: unknown user

       

      Any idea what I'm doing wrong?

        • 1. Re: blquery issues

          I fixed this by changing the first nested single quote to a double quote, and escaping any other double quotes in between:

           

          blquery -e 'user_record_count ("user_type (NAME) = BUA_ADMIN_ACCOUNT && ( ! user_disabled (NAME) && ( ! user_locked (NAME) && printf (\"%s - %s\n\", HOSTNAME, NAME)));");'

          • 2. Re: blquery issues

            Greg,

             

            BLQuery is tricky with the quotes. With the -e command, you need to put the function in single quotes, and then the string parameter in double quotes. Since the parameter is in double quotes, any embedded parameters that need quotes (i.e. printf) will need to be escaped with the \.

             

            This worked for me:

             

            dominica% blquery -e 'user_record_count ("user_type (NAME) = BUA_ADMIN_ACCOUNT &

            & (!user_disabled (NAME) && (!user_locked (NAME) && printf(\"%s - %s\n\", HOSTNA

            ME, NAME)))");'

            dominica - Administrator

             

            I always get it mixed up, too. I just check the blquery man page for a refresher...

             

            Justin

             

             

            --- Nice, you beat me to it!

             

            Message was edited by:

            Justin Suissa