TR can be used to convert a list of items from one per line to space separated with this:
1 |
tr '\r\n' ' ' |
TR can be used to convert a list of items from one per line to space separated with this:
1 |
tr '\r\n' ' ' |
Recently needed a good way to fetch the IP address of each interface within a script. Tried things like:
1 |
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' |
and
1 |
/sbin/ifconfig | sed -n '2 p' | awk '{print $3}' |
But this is fairly ugly. So I tried:
1 |
hostname -I |
This gives a list of IP addresses but they are un-ordered so I can’t guarantee which address goes with which interface. Here’s one using “ip addr”:
1 |
ip=$(ip -f inet -o addr show eth0|cut -d\ -f 7 | cut -d/ -f 1) |
Still very messy. Finally, found the “ifdata” command which is part of the “moreutils” package. First make sure “moreutils” is installed with:
1 |
yum -y install moreutils |
Now you can query for a wide range of different information:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
Usage: ifdata [options] iface -e Reports interface existence via return code -p Print out the whole config of iface -pe Print out yes or no according to existence -pa Print out the address -pn Print netmask -pN Print network address -pb Print broadcast -pm Print mtu -ph Print out the hardware address -pf Print flags -si Print all statistics on input -sip Print # of in packets -sib Print # of in bytes -sie Print # of in errors -sid Print # of in drops -sif Print # of in fifo overruns -sic Print # of in compress -sim Print # of in multicast -so Print all statistics on output -sop Print # of out packets -sob Print # of out bytes -soe Print # of out errors -sod Print # of out drops -sof Print # of out fifo overruns -sox Print # of out collisions -soc Print # of out carrier loss -som Print # of out multicast -bips Print # of incoming bytes per second -bops Print # of outgoing bytes per second |
So here are some examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@host]# ifdata -pa eth0 10.210.160.53 [root@host]# ifdata -pa eth0 10.210.160.53 [root@host]# ifdata -pn eth0 255.255.224.0 [root@host]# ifdata -sip eth0 1622384587 [root@host]# ifdata -bops eth0 896 |
Overall this is much cleaner and more reliable then the earlier approaches.
Applying the new SUPEE-7405 patch to Magento 1.7.0.2 (and probably other versions) results in a parse error in the sales order view page (admin/sales_order/view/order_id) if the site is running under PHP5.3. Here’s the error message:
1 2 |
PHP message: PHP Parse error: syntax error, unexpected '[' in /app/code/core/Mage/Adminhtml/Helper/Sales.php on line 124 |
The offending line is:
1 |
$links = []; |
it can be changed to:
1 |
$links = array(); |
PHP 5.3 does not support the “[]” syntax for array initialization. Of course you should not be running PHP 5.3!
Recent on servers with Plesk 12 and the PHP 5.3 distribution from Odin, we’re seeing “abrt” crash reports from Yum with a back trace like:
1 2 |
:miscutils.py:71:checkSig:OSError: [Errno 2] No such file or directory: '/var/cache/yum/x86_64/7/plesk-php-5.3/packages/plesk-php53-ioncube-loader-5.0.18-centos7.15101218.x86_64.rpm' |
Until Odin fixes their repository the only way to get updates to proceed normally is to disable the PHP 5.3 repository by editing:
1 |
/etc/yum.repos.d/plesk-php5.3.repo |
And adding this line:
1 |
enabled=0 |
Since PHP 5.3 is EOL there aren’t any updates expected so disabling the repository should not cause problems.
The Yoast SEO plugin in WordPress has started advising users to upgrade curl to the latest version. On CentoOS this can be done easily using the city-fan.org repo here:
http://www.city-fan.org/ftp/contrib/yum-repo/
For a CentOS 6 server, here are the steps:
1 2 |
rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpm yum install libcurl |