Redirecting hammer output to a file

I would like to use hammer to search all hosts matching a certain search
spec, and dump that in to a text file to be used by another script.

For example this gives me all the hosts that have the hostgroup "foo" and
that have "bar" in their name:

hammer --csv host list --per-page 9999 --search "bar and hostgroup = foo".

This command asks for a username and password, and then outputs a nice csv
formatted list of hosts matching the search spec.

However, if I try to redirect the ouput to a file this does not work, as
the usernam and password prompt gets lost.
I can of course add -u and -p options, but I would rather not have my
password visible on the prompt.

So is there a way to redirect the output of hammer to a file, while at the
same time still have it prompt for a password?

Krist

> I would like to use hammer to search all hosts matching a certain search
> spec, and dump that in to a text file to be used by another script.
>
> For example this gives me all the hosts that have the hostgroup "foo" and
> that have "bar" in their name:
>
> hammer --csv host list --per-page 9999 --search "bar and hostgroup = foo".
>
> This command asks for a username and password, and then outputs a nice csv
> formatted list of hosts matching the search spec.
>
> However, if I try to redirect the ouput to a file this does not work, as
> the usernam and password prompt gets lost.
> I can of course add -u and -p options, but I would rather not have my
> password visible on the prompt.
>
> So is there a way to redirect the output of hammer to a file, while at the
> same time still have it prompt for a password?

I'd file an issue for us to prompt for username/password on stderr,
instead of stdout. I think that's a pretty typical thing to do.

Foreman

Password visible on the CLI isn't ideal, but if you put a space before
the command at least most shells won't add it to the history.

You should also be able to store the username/password combo in a config
file in your home directory.

··· On Tue, Apr 07, 2015 at 02:57:08AM -0700, Krist van Besien wrote:

Krist


You received this message because you are subscribed to the Google Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


Best Regards,

Stephen Benjamin
Red Hat Engineering