How to get `yum list` output to stay on one line when getting output via remote ssh command?
Clash Royale CLAN TAG#URR8PPP
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
ssh terminal pipe
|
show 1 more comment
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
ssh terminal pipe
1
stackoverflow.com/questions/18964478/…
– thrig
Apr 7 '16 at 15:55
cannot reproduce on centos 7
– sivann
Apr 7 '16 at 16:21
1
Note also thatyum 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.
– larsks
Apr 7 '16 at 16:52
Doesssh -t machine 'yum list'
solve the problem?
– egmont
Apr 7 '16 at 18:55
1
idk if this would solve in your specific situation, but often piping tocat
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.
– RubyTuesdayDONO
May 17 '18 at 20:00
|
show 1 more comment
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
ssh terminal pipe
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
ssh terminal pipe
ssh terminal pipe
asked Apr 7 '16 at 15:49
MitchMitch
5332719
5332719
1
stackoverflow.com/questions/18964478/…
– thrig
Apr 7 '16 at 15:55
cannot reproduce on centos 7
– sivann
Apr 7 '16 at 16:21
1
Note also thatyum 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.
– larsks
Apr 7 '16 at 16:52
Doesssh -t machine 'yum list'
solve the problem?
– egmont
Apr 7 '16 at 18:55
1
idk if this would solve in your specific situation, but often piping tocat
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.
– RubyTuesdayDONO
May 17 '18 at 20:00
|
show 1 more comment
1
stackoverflow.com/questions/18964478/…
– thrig
Apr 7 '16 at 15:55
cannot reproduce on centos 7
– sivann
Apr 7 '16 at 16:21
1
Note also thatyum 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.
– larsks
Apr 7 '16 at 16:52
Doesssh -t machine 'yum list'
solve the problem?
– egmont
Apr 7 '16 at 18:55
1
idk if this would solve in your specific situation, but often piping tocat
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.
– RubyTuesdayDONO
May 17 '18 at 20:00
1
1
stackoverflow.com/questions/18964478/…
– thrig
Apr 7 '16 at 15:55
stackoverflow.com/questions/18964478/…
– thrig
Apr 7 '16 at 15:55
cannot reproduce on centos 7
– sivann
Apr 7 '16 at 16:21
cannot reproduce on centos 7
– sivann
Apr 7 '16 at 16:21
1
1
Note also that
yum list
does not list everything that is installed (it lists everything that is available). For a list of installed packages, you probably want rpm -qa
, the output of which is much more suitable for scripting parsing. In particular, also see the documentation for the --queryformat
option to the rpm
command.– larsks
Apr 7 '16 at 16:52
Note also that
yum list
does not list everything that is installed (it lists everything that is available). For a list of installed packages, you probably want rpm -qa
, the output of which is much more suitable for scripting parsing. In particular, also see the documentation for the --queryformat
option to the rpm
command.– larsks
Apr 7 '16 at 16:52
Does
ssh -t machine 'yum list'
solve the problem?– egmont
Apr 7 '16 at 18:55
Does
ssh -t machine 'yum list'
solve the problem?– egmont
Apr 7 '16 at 18:55
1
1
idk if this would solve in your specific situation, but often piping to
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.– RubyTuesdayDONO
May 17 '18 at 20:00
idk if this would solve in your specific situation, but often piping to
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.– RubyTuesdayDONO
May 17 '18 at 20:00
|
show 1 more comment
3 Answers
3
active
oldest
votes
Install expect, which comes with unbuffer(1), and run:
# unbuffer yum repolist
add a comment |
Per this answer provided in the comments by @thrig I was able to get it to output correctly by doing
yum list installed | xargs -n3 | column -t
I'd be curious to hear if my proposal (in a comment above) works for you; that'd be way simpler and catch the real cause why combining ssh and yum in a single step gives a different result than interactively logging in and executing yum remotely. I don't have a remote machine to test my theory.
– egmont
Apr 8 '16 at 18:56
Slightly modified:yum list installed | tail -n +5 | xargs -n3 | column -t | less
cleans off the crud for unregistered redhat systems.
– EdwinW
Dec 11 '18 at 2:13
@egmont I tried your idea, and it worked quite well.
– EdwinW
Dec 11 '18 at 2:18
add a comment |
I fought with this today (during a yum check-update
operation) and after finding a "CLOSED NOTABUG" bugzilla report and various python hacks, I came up with yet another workaround:
script -q -c "stty cols 150; yum check-update" /dev/null > /path/to/output.txt 2>&1
or:
script -q -c "stty cols 150; yum check-update" /path/to/output.txt > /dev/null
150 was an arbitrarily large-enough number to prevent wrapping; adjust that upwards if needed. The -q
option inhibits the initial "Script started on $(date)" line, if you use a non-null output filename.
For the original problem, the line would be:
script -q -c "stty cols 150; yum list" /dev/null
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f274938%2fhow-to-get-yum-list-output-to-stay-on-one-line-when-getting-output-via-remote%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Install expect, which comes with unbuffer(1), and run:
# unbuffer yum repolist
add a comment |
Install expect, which comes with unbuffer(1), and run:
# unbuffer yum repolist
add a comment |
Install expect, which comes with unbuffer(1), and run:
# unbuffer yum repolist
Install expect, which comes with unbuffer(1), and run:
# unbuffer yum repolist
answered Jan 27 '17 at 9:28
Gerrit A. SmitGerrit A. Smit
212
212
add a comment |
add a comment |
Per this answer provided in the comments by @thrig I was able to get it to output correctly by doing
yum list installed | xargs -n3 | column -t
I'd be curious to hear if my proposal (in a comment above) works for you; that'd be way simpler and catch the real cause why combining ssh and yum in a single step gives a different result than interactively logging in and executing yum remotely. I don't have a remote machine to test my theory.
– egmont
Apr 8 '16 at 18:56
Slightly modified:yum list installed | tail -n +5 | xargs -n3 | column -t | less
cleans off the crud for unregistered redhat systems.
– EdwinW
Dec 11 '18 at 2:13
@egmont I tried your idea, and it worked quite well.
– EdwinW
Dec 11 '18 at 2:18
add a comment |
Per this answer provided in the comments by @thrig I was able to get it to output correctly by doing
yum list installed | xargs -n3 | column -t
I'd be curious to hear if my proposal (in a comment above) works for you; that'd be way simpler and catch the real cause why combining ssh and yum in a single step gives a different result than interactively logging in and executing yum remotely. I don't have a remote machine to test my theory.
– egmont
Apr 8 '16 at 18:56
Slightly modified:yum list installed | tail -n +5 | xargs -n3 | column -t | less
cleans off the crud for unregistered redhat systems.
– EdwinW
Dec 11 '18 at 2:13
@egmont I tried your idea, and it worked quite well.
– EdwinW
Dec 11 '18 at 2:18
add a comment |
Per this answer provided in the comments by @thrig I was able to get it to output correctly by doing
yum list installed | xargs -n3 | column -t
Per this answer provided in the comments by @thrig I was able to get it to output correctly by doing
yum list installed | xargs -n3 | column -t
edited Jul 13 '17 at 21:27
rogerdpack
3531313
3531313
answered Apr 8 '16 at 18:52
MitchMitch
5332719
5332719
I'd be curious to hear if my proposal (in a comment above) works for you; that'd be way simpler and catch the real cause why combining ssh and yum in a single step gives a different result than interactively logging in and executing yum remotely. I don't have a remote machine to test my theory.
– egmont
Apr 8 '16 at 18:56
Slightly modified:yum list installed | tail -n +5 | xargs -n3 | column -t | less
cleans off the crud for unregistered redhat systems.
– EdwinW
Dec 11 '18 at 2:13
@egmont I tried your idea, and it worked quite well.
– EdwinW
Dec 11 '18 at 2:18
add a comment |
I'd be curious to hear if my proposal (in a comment above) works for you; that'd be way simpler and catch the real cause why combining ssh and yum in a single step gives a different result than interactively logging in and executing yum remotely. I don't have a remote machine to test my theory.
– egmont
Apr 8 '16 at 18:56
Slightly modified:yum list installed | tail -n +5 | xargs -n3 | column -t | less
cleans off the crud for unregistered redhat systems.
– EdwinW
Dec 11 '18 at 2:13
@egmont I tried your idea, and it worked quite well.
– EdwinW
Dec 11 '18 at 2:18
I'd be curious to hear if my proposal (in a comment above) works for you; that'd be way simpler and catch the real cause why combining ssh and yum in a single step gives a different result than interactively logging in and executing yum remotely. I don't have a remote machine to test my theory.
– egmont
Apr 8 '16 at 18:56
I'd be curious to hear if my proposal (in a comment above) works for you; that'd be way simpler and catch the real cause why combining ssh and yum in a single step gives a different result than interactively logging in and executing yum remotely. I don't have a remote machine to test my theory.
– egmont
Apr 8 '16 at 18:56
Slightly modified:
yum list installed | tail -n +5 | xargs -n3 | column -t | less
cleans off the crud for unregistered redhat systems.– EdwinW
Dec 11 '18 at 2:13
Slightly modified:
yum list installed | tail -n +5 | xargs -n3 | column -t | less
cleans off the crud for unregistered redhat systems.– EdwinW
Dec 11 '18 at 2:13
@egmont I tried your idea, and it worked quite well.
– EdwinW
Dec 11 '18 at 2:18
@egmont I tried your idea, and it worked quite well.
– EdwinW
Dec 11 '18 at 2:18
add a comment |
I fought with this today (during a yum check-update
operation) and after finding a "CLOSED NOTABUG" bugzilla report and various python hacks, I came up with yet another workaround:
script -q -c "stty cols 150; yum check-update" /dev/null > /path/to/output.txt 2>&1
or:
script -q -c "stty cols 150; yum check-update" /path/to/output.txt > /dev/null
150 was an arbitrarily large-enough number to prevent wrapping; adjust that upwards if needed. The -q
option inhibits the initial "Script started on $(date)" line, if you use a non-null output filename.
For the original problem, the line would be:
script -q -c "stty cols 150; yum list" /dev/null
add a comment |
I fought with this today (during a yum check-update
operation) and after finding a "CLOSED NOTABUG" bugzilla report and various python hacks, I came up with yet another workaround:
script -q -c "stty cols 150; yum check-update" /dev/null > /path/to/output.txt 2>&1
or:
script -q -c "stty cols 150; yum check-update" /path/to/output.txt > /dev/null
150 was an arbitrarily large-enough number to prevent wrapping; adjust that upwards if needed. The -q
option inhibits the initial "Script started on $(date)" line, if you use a non-null output filename.
For the original problem, the line would be:
script -q -c "stty cols 150; yum list" /dev/null
add a comment |
I fought with this today (during a yum check-update
operation) and after finding a "CLOSED NOTABUG" bugzilla report and various python hacks, I came up with yet another workaround:
script -q -c "stty cols 150; yum check-update" /dev/null > /path/to/output.txt 2>&1
or:
script -q -c "stty cols 150; yum check-update" /path/to/output.txt > /dev/null
150 was an arbitrarily large-enough number to prevent wrapping; adjust that upwards if needed. The -q
option inhibits the initial "Script started on $(date)" line, if you use a non-null output filename.
For the original problem, the line would be:
script -q -c "stty cols 150; yum list" /dev/null
I fought with this today (during a yum check-update
operation) and after finding a "CLOSED NOTABUG" bugzilla report and various python hacks, I came up with yet another workaround:
script -q -c "stty cols 150; yum check-update" /dev/null > /path/to/output.txt 2>&1
or:
script -q -c "stty cols 150; yum check-update" /path/to/output.txt > /dev/null
150 was an arbitrarily large-enough number to prevent wrapping; adjust that upwards if needed. The -q
option inhibits the initial "Script started on $(date)" line, if you use a non-null output filename.
For the original problem, the line would be:
script -q -c "stty cols 150; yum list" /dev/null
answered Feb 8 at 20:26
Jeff SchallerJeff Schaller
42.9k1159137
42.9k1159137
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f274938%2fhow-to-get-yum-list-output-to-stay-on-one-line-when-getting-output-via-remote%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
stackoverflow.com/questions/18964478/…
– thrig
Apr 7 '16 at 15:55
cannot reproduce on centos 7
– sivann
Apr 7 '16 at 16:21
1
Note also that
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.– larsks
Apr 7 '16 at 16:52
Does
ssh -t machine 'yum list'
solve the problem?– egmont
Apr 7 '16 at 18:55
1
idk if this would solve in your specific situation, but often piping to
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.– RubyTuesdayDONO
May 17 '18 at 20:00