Top Nav

Archive | Scripting

Get IP Address In A Script

Recently needed a good way to fetch the IP address of each interface within a script. Tried things like:

and

But this is fairly ugly. So I tried:

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”:

Still very messy.  Finally, found the “ifdata” command which is part of the “moreutils” package. First make sure “moreutils” is installed with:

Now you can query for a wide range of different information:

So here are some examples:

Overall this is much cleaner and more reliable then the earlier approaches.

0

Magento SUPEE-7405 Parse Error

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:

The offending line is:

it can be changed to:

PHP 5.3 does not support the “[]” syntax for array initialization. Of course you should not be running PHP 5.3!

0

Plesk 12 / CentOS / PHP 5.3 Issue Causes “abrt” Crash From Yum

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:

Until Odin fixes their repository the only way to get updates to proceed normally is to disable the PHP 5.3 repository by editing:

And adding this line:

Since PHP 5.3 is EOL there aren’t any updates expected so disabling the repository should not cause problems.

 

0

Upgrade CURL

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:

 

 

0