Tip : jq -r to get raw value instead of quoted strings
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
-
@rickfillion: Who is your target audience? HAL9000? ;)
0 -
@brenty : people who are comfortable with shell scripting.
0 -
<3
0 -
@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 :)
0 -
@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.
0 -
Sounds good @rickfillion, when and if you need some help with that, I'd be happy to help out with the docs.
0