parsable yum output

Issues related to applications and software problems
Post Reply
forumitu
Posts: 118
Joined: 2014/02/20 14:30:51

parsable yum output

Post by forumitu » 2018/12/04 07:49:16

I want to use the output of the

Code: Select all

yum -q check-update
in a script. My problem is that the output is formatted strange way, hard, if not impossible to parse, for example:

Code: Select all

yum.noarch                     3.4.3-161.el7.centos     base                    
yum-plugin-fastestmirror.noarch
                               1.1.31-50.el7            base                    
yum-plugin-protectbase.noarch  1.1.31-50.el7            base                    
Seemingly if the packages name reach certain predefined ad-hoc size limit, the yum command inserts arbitrary line break to mangle the output.
Is there a flag to yum that I am interested in getting a raw output of the data, no human will directly read it?

lightman47
Posts: 1521
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: parsable yum output

Post by lightman47 » 2018/12/07 20:16:51

It inserted a linefeed and a tab or two after the extra long "yum-plugin-fastestmirror.noarch" - or your terminal session did so it would fit your session screen. In either case, should be moderately easy for a script to deal with I'd think

??

forumitu
Posts: 118
Joined: 2014/02/20 14:30:51

Re: parsable yum output

Post by forumitu » 2018/12/10 12:52:42

Thanks for the reply. I got this result through an ssh session without controlling terminal and the output directly redirected into a file and all scheduled from crontab. So there could not be any screen involved in the formatting.

You are right, I will be obliged to reverse-format the ugliness of the yum's output since seemingly there is no "--raw" option or similar function of yum, at least nobody else confirmed differently.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: parsable yum output

Post by TrevorH » 2018/12/10 13:51:31

Yum has a python api that you might use instead.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

forumitu
Posts: 118
Joined: 2014/02/20 14:30:51

Re: parsable yum output

Post by forumitu » 2018/12/10 14:00:40

Thanks TrevorH,

I may try using the API. For the time being it seem quicker to mangle back the output, even it might be less reliable than the API.

Post Reply