When I SSH to a machine with ssh machine
and run yum list
it outputs everything that's installed as expected, and importantly every item is on one line like so:
xz-devel.i386 4.999.9-0.3.beta.20091007git.el5 base
xz-devel.x86_64 4.999.9-0.3.beta.20091007git.el5 base
xz-libs.i386 4.999.9-0.3.beta.20091007git.el5 base
xz-lzma-compat.x86_64 4.999.9-0.3.beta.20091007git.el5 base
But upon doing it remotely with ssh machine 'yum list'
or even piping it to grep while on the server with yum list | grep xz -C 3
the output's lines are "truncated" and made much shorter, like so:
xz-devel.i386 4.999.9-0.3.beta.20091007git.el5
base
xz-devel.x86_64 4.999.9-0.3.beta.20091007git.el5
base
xz-libs.i386 4.999.9-0.3.beta.20091007git.el5
base
xz-lzma-compat.x86_64 4.999.9-0.3.beta.20091007git.el5
base
How can I make the size of the line not shrink like this? My end desire is to pipe this to tee
and then do some processing on the outputted file for all my hosts via ansible.
It seems that this is occurring due to some sort of "virtual terminal" as part of the SSH/piping because I can get the same behavior if I shrink my terminal size where the lines break when running yum list
. Thus I'd assume that the addition of the pipe somehow tells yum list
that the width of the terminal is only X columns
yum list
does not list everything that is installed (it lists everything that is available). For a list of installed packages, you probably wantrpm -qa
, the output of which is much more suitable for scripting parsing. In particular, also see the documentation for the--queryformat
option to therpm
command.ssh -t machine 'yum list'
solve the problem?cat
is enough to tell a program that stdout isn't a tty, and therefore don't prettify output. w/ yum, for example, doing that will prevent right-justification of the trailing columns.