Tip : jq -r to get raw value instead of quoted strings

rickfillionrickfillion Junior Member

Team Member

I just fixed up my example script that invoked mysql with credentials. It was getting the username and password out of the item via jq which returned quoted strings. This caused issues that I didn't anticipate in the mysql invocation. By using -r it works as expected.

Here's my actual working example:

#!/bin/bash
S=$(./op login agilebits) &&
D=$(./op item $S "MySQL localdatabase") &&
USERNAME=$(echo $D | jq -r '.fields[] | select(.designation=="username").value') &&
PASSWORD=$(echo $D | jq -r '.fields[] | select(.designation=="password").value') &&
mysql --host=b5local.com --port=3306 -u $USERNAME --password=$PASSWORD --database=b5

Comments

  • brentybrenty

    Team Member

    @rickfillion: Who is your target audience? HAL9000? ;)

  • rickfillionrickfillion Junior Member

    Team Member

    @brenty : people who are comfortable with shell scripting.

  • brentybrenty

    Team Member

    <3

  • DanielPDanielP

    Team Member

    @rickfillion Do we have a place where we store some documentation about this, or are we just using this forum section for now? I would love to play around with this a little bit if I had some more information :)

  • rickfillionrickfillion Junior Member

    Team Member

    @DanielP : no documentation is ready yet beyond the help that the CLI app provides itself. This forum category is private an only available to us AgileBits employees and the external people who have been given early access to the CLI app.

  • DanielPDanielP

    Team Member

    Sounds good @rickfillion, when and if you need some help with that, I'd be happy to help out with the docs.

This discussion has been closed.