Page 1 of 1

grep Option -o

Posted: 2018/12/10 11:34:07
by r_a_mueller
Hallo,
I have an Edomi-Server running with CentOS 6.5. Now I wanted to give the server another task. It should run a shell script. In Ubuntu this script worked well, it should extract a certain value from a web page. It used grep with option -o (only matching) and head -1 to extract the value without the surroundig contents. Because the pattern matches to three values on this site, the attached "head -1" guarantees that only the first one is extracted.

Under CentOS the script stops before the grep command. On the CentOS manpage for grep I did not find this option -o. Is there an alternative? Can I install a different package, where grep contains this option?

Thank you very much

-richard

Re: grep Option -o

Posted: 2018/12/10 11:49:04
by TrevorH
First thing: CentOS 6.5 is nearly 5 years old so if you haven't run yum update recently then you really really need to do so. You have a server that has 5 years worth of security vulnerabilities on it and some of those are serious.

Running man grep on a 6.10 system shows
-o, --only-matching
Print only the matched (non-empty) parts of a matching line, with each such part on a
separate output line.

Re: grep Option -o

Posted: 2018/12/10 14:47:03
by r_a_mueller
Thanks for your hint. The Edomi software which runs on this machine is optimized for CentOS 6.5. Therefore I don't want to update it, if there are serious threats perhaps I could close the internet connection to this computer. I just looked for a computer running 24/7 to additionally run my small script once a day, and so I thought, take this one!
I tried to use a Fritzbox, but unfortunately they have closed the Telnet-entrance.

Re: grep Option -o

Posted: 2018/12/10 21:08:17
by TrevorH
The Edomi software which runs on this machine is optimized for CentOS 6.5.
The whole point of CentOS and RHEL is that the ABI stays the same for the entire 10 year lifespan of the distro. It should make no difference if you run 6.5 or 6.10 from that POV. What does make a difference is that there are nearly 200 different security bugs fixed between 6.5 and now that are marked as "critical". That doesn't count the ones marked as merely "important" or the other categories less severe than that.

Re: grep Option -o

Posted: 2018/12/14 09:28:06
by jlehtone
What does "optimized for X" mean anyway?
(Marketing speech doesn't count.)

Re: grep Option -o

Posted: 2018/12/14 16:01:03
by r_a_mueller
The developer of Edomi freeware says that he focuses on Edomi, not the used OS and does not want to adapt his software for different OSs. Edomi runs on small computers for house automization usually 24/7, so I thought I could use this computer for another scipt, whose activating schme is controlled by Cron. Meanwhile I used yum update on the system, but it seems it forgot its IP, so I can not access it via ssh as usually. I'll try to get it running again on the weekend.

Re: grep Option -o

Posted: 2018/12/15 04:29:48
by Whoever
There is a dockerized version of Edomi. That might be a better way to go because you can run it on the latest version of the OS. You could run it on CentOS 7.

Re: grep Option -o

Posted: 2018/12/17 18:42:43
by r_a_mueller
Thanks for the hint. I had troubles installing version 7, so I installed 6.10 in a minimal version. For 7 it said, that the harddisk is too small (33 GB SSD). Perhaps I should have tried the minimal 7. version without graphical desktops etc. But now everything works.
Thanks for your help, folks!

-richard