Awk Floating Point Number Addition Results Are Unexpected

I am using awk to grep ‘foo’ from a text file and cacluate sum of field # 7. But, result is rounded to an integer. I need exact result such as 385858.66 and not 385858 using the following command:

grep ‘foo’ 2012-2013.txt | awk ‘BEGIN{ sum=0.0}{ sub(“,”,””,$7); sum +=$7}END{ print “$” sum}’ $682444

I want $682444.57 as output. How can I force “awk” to do floating point math?

Read answer to: “Awk Floating Point Number Addition Results Are Unexpected

Tweet this    Share on Facebook

Powered by WPeMatico

Linux: Find Out How Much Disk Space Left On Hard Drive

I am a desktop support professional with experience working in a corporate call center environment. Recently, I started to admin RHEL based IBM Linux server. How do I determine how much disk space left in my Linux server? How do I find out how much disk space I have in Linux for each partition?

Read answer to: “Linux: Find Out How Much Disk Space Left On Hard Drive

Tweet this    Share on Facebook

Powered by WPeMatico

How to check the current PHP handler and change it

[root@server ~]# /usr/local/cpanel/bin/rebuild_phpconf –current
Available handlers: suphp dso cgi none
DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: cgi
SUEXEC: not installed

[root@server ~]# /usr/local/cpanel/bin/rebuild_phpconf 4 dso none 1

[root@server ~]# /usr/local/cpanel/bin/rebuild_phpconf –current
Available handlers: suphp dso cgi none
DEFAULT PHP: 4
PHP4 SAPI: dso
PHP5 SAPI: none
SUEXEC: enabled

[root@server ~]# /usr/local/cpanel/bin/rebuild_phpconf –help
======================================
Usage:-
/usr/local/cpanel/bin/rebuild_phpconf [–dryrun] [–no-restart]
[–no-user-updates]
[–current|–available]
–dryrun : Only display the changes that would be made
–no-restart : Don’t restart Apache after updating the php.conf link
–no-htaccess : Don’t update user configurable PHP mime mapping.
–current : Show current settings
–available : Show available handlers and PHP SAPIs
: Version of PHP to set as default handler for .php files
: Type of Apache module to use in serving PHP requests
: enabled, disabled, 1 or 0
======================================

The Five Types of PHP Configuration That Are Possible:-
====================================================
* None – Don’t provide access to this version of PHP
*DSO – Provide this version of PHP via libphp4.so or libphp5.so ( mod_php). This is normally the fastest possible way to serve PHP requests, but PHP will execute as the user “nobody”. If both versions of PHP are available, it is impossible to configure both to be served as DSO unless the concurrent DSO patch was applied at build time.
* SuPHP – Provide this version of PHP through mod_suphp. This is the most flexible way of serving PHP requests and tends to be very secure. PHP scripts are executed by the user who owns the VirtualHost serving the request.
* FCGI – Provide this version of PHP through mod_fcgid. This is a very fast way of serving PHP requests, but php.conf will most likely require additional tuning to perform well. If Suexec is enabled, each user will create their own PHP FastCGI server automatically and PHP scripts will be executed by the user who owns the VirtualHost serving the request. If Suexec is disabled, the “nobody” user will own all of the PHP FastCGI server processes and PHP scripts will be executed by the “nobody” user. FCGI mode is recommended only for advanced administrators who understand how to tune the performance of mod_fcgid. Userdir requests will not function correctly with the basic mod_fcgid setup provided by cPanel.
* CGI – Provide this version of PHP through mod_cgi or mod_cgid. If Suexec is enabled, PHP scripts will be executed by the user who owns the VirtualHost serving the request. If Suexec is disabled, the “nobody” user will execute all PHP scripts. Userdir requrests will not function correctly with the basic CGI setup provided by cPanel. It is intended as a fallback when the other preferred methods (DSO or SuPHP) are not available. Serving PHP as CGI is not particularly secure or fast regardless of whether Suexec is enabled.
=======================================================

source: http://openhelp.net/2009/05/10/how-to-change-the-default-php-handler-from-the-command-prompt-cpanel-server/

Reliable Shared Hosting

Magento error: Your web server is configured incorrectly. As a result, configuration files with sensitive information are accessible from the outside. Please contact your hosting provider.

Magento error:
Your web server is configured incorrectly. As a result, configuration files with sensitive information are accessible from the outside. Please contact your hosting provider.

Solution:
This error is caused by /app/etc/local.xml being readable by the world. Set the permissions to 551

How to check Plesk version and update the admin password

You can type:

rpm -q psa

or

cat /usr/local/psa/version

The password is located under:

/etc/psa/.psa.shadow

Serve files with no extension as PHP

So I recently wget mirrored a whole website and uploaded them to my web server. The PHP files from the original server had no extension and when trying to load them, Apache did not serve them as PHP, loading a bunch of jibberish.

To solve this problem, I had to edit .htaccess :


< FilesMatch '^[^.]+$' >
ForceType application/x-httpd-php
< /FilesMatch >

#OR

#AddHandler server-parsed .php

#SetHandler application/x-httpd-php

#AddHandler application/x-httpd-php .php

#OR

#RewriteEngine On
#RewriteRule ^[^.]+$ – [T=application/x-httpd-php,L]