Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, September 19, 2010

Find your SuSE version

From time to time I need to find the SuSE version for the box I'm connected to.
So all I need to do is type the following command into a console:

cat /etc/SuSE-release

Another option is to use the following command:

lsb_release -a

Good to know.

Monday, May 17, 2010

PHP broken email

There are cases when an email might end up showing the headers inside the email's body. This means that headers are usually.

We had a big headache with a PHP project lately as all the emails were broken ("butchered" as someone said).

Here is how a test the email looked like:

MIME-Version: 1.0
Content-type: text/html; charset=utf-8
Message-Id: <...........>
Date: Mon, 17 May 2010 10:52:35 +0300 (EEST)
From: root@snow.zzzptoid.com (root)




Yes, a simple HTML email test
Now we took a look at the raw email and here is what we saw:
Received: (qmail 9464 invoked from network); 17 May 2010 07:51:47 -0000
Received: from unknown (HELO m1pismtp01-011.prod.mesa1.secureserver.net) ([10.8.12.11])
(envelope-sender )
by p3plsmtp03-04.prod.phx3.secureserver.net (qmail-1.03) with SMTP
for ; 17 May 2010 07:51:47 -0000
X-IronPort-Anti-Spam-Result: AqoFAAiS8EtZLcluX2dsb2JhbACRfQEBixsDbB5IvwkEiQ8
Received: from pc110.fx-net.ro (HELO snow.zzzptoid.com) ([89.45.201.120])
by m1pismtp01-011.prod.mesa1.secureserver.net with ESMTP; 17 May 2010 00:51:46 -0700
Received: by snow.zzzptoid.com (Postfix, from userid 0)
id 2FF74F04FB; Mon, 17 May 2010 10:52:35 +0300 (EEST)
To: alex@zzzptoid.com
Subject: Test HTML email
X-PHP-Originating-Script: 0:testSendEmail.php
X-Nonspam: Statistical 50%

MIME-Version: 1.0
Content-type: text/html; charset=utf-8
Message-Id: <...>
Date: Mon, 17 May 2010 10:52:35 +0300 (EEST)
From: root@snow.zzzptoid.com (root)


Yes, a simple HTML email test

Now the problem were those 3 lines :
X-Nonspam: Statistical 50%

MIME-Version: 1.0
There should be no blank line between headers as the email parser will believe that the headers are done and the content is starting.

Where do those extra line coming from? They are added by PHP for any email sent, so we need to remove them; and they are added the wrong way - introducing an unnecessary blank line.

Go to php.ini and set mail.add_x_headers to off:

mail.add_x_headers = Off

Now restart you Apache and let me know if it's working :)

Carriage return and Line feed

If I work too much under Linux (x)or Windows and I want to switch to the other operating system I bump into the new line issue.

Here are the actors:

CR - carriage return, ASCII code 10 (or \r) - means that the printer carriage should return at the beginning of the line

LF - line feed, ASCII code 13 (or \n) - means that the printer carriage should be move on next line.

New line - whenever you need to move to a new line (in console or editor)


Windows and Linux treat that new line differently:

Window - the new line is made out of a CR and LF so actually the code for new line is CR+LF (\r\n)

Linux - the new line is a simple line feed = LF (\n)

Thursday, May 28, 2009

Linux - count my processes

Whenever I'm in need to count how many processes are running on my Linux box I use:

ps aux | wc -l


Mount Samba remote folders - Suse Linux

The need:
I needed to mount a remote (located on 10.0.0.7) Samba folder (named solaria) so that I can use .iso file without downloading it to my local machine (Suse 11.1)

The solution
You can mount the remote driver by hand but I'm lazy so I want it mounted automatically so here is what I did:

1. Created a [solaria] folder in /mnt folder

2. Added the following line in /etc/fstab
//10.0.0.7/solaria/ /mnt/solaria cifs auto,password= 0 0

Now the next time you start you OS you will see the content of the remote folder in your /mnt/fstab

See that I used a blank (no) password for the smb account as I allow guest logins

You can also mount it with the next command
mount /mnt/solaria
and unmount it with
umount /mnt/solaria

Note
One interesting stuff is that the old smbfs was renamed to cifs. Here is where I found this information.

Thursday, March 26, 2009

Linux: sort your folder by size

In case you need to sort your folders by size, in Linux, you can use the following command:

du --max-depth=1 /home/ | sort -n -r

of course replace '/home/' with your desired folder.