Ask Your Question

Format output of command line clients

asked 2015-11-25 04:35:06 -0500

Carlos Campderrós gravatar image

Is there any way to change/format the output of command line tools like nova? I'm looking for some way of easily parsing the output in shell scripts, without having to resort to the novaclient python library.

Specifically I'm trying to get the status field of an instance. Right now I'm doing some parsing with sed and awk, but it is ugly.

It would be wonderful if I could do something like (strongly based on rpm -q --queryformat):

status=$(nova show --format="%{status}" my-instance-name)
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2015-11-25 04:31:48 -0500

Carlos Campderrós gravatar image

After posting the question I just found what I wanted. There is the openstack command that I didn't know that existed (yum install python-openstackclient in fedora) that covers what I need:

status="$(openstack server show -c status --format value my-instance-name)"
edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-11-25 03:56:58 -0500

Seen: 6,178 times

Last updated: Nov 25 '15