Nasrul Hazim Bin Mohamad

CakePHP: Running Shell Script with Cronjob


Create a Shell Script

Create a ScheduleShell.php in cakephp/app/Console/Command.

class ScheduleShell extends Shell {
    function main() {
    	$this->out('Hello World');

Add a cronjob

sudo crontab -e

I have a cronjob running every 5 minute for ScheduleShell.php

# cronjob run every 5 minute
*/5  *    *    *    * cd /var/www/html/cakephp/app && Console/cake schedule

Ubuntu: LDAP – Install, Configure & Test


I’m using Ubuntu 12.04

LDAP: Install & Configure

  1. sudo apt-get install slapd ldap-utils
    1. Enter password: [SetY0urP@$$wOrD]
  2. dpkg-reconfigure slapd
    1. Omit OpenLDAP server configuration? No
    2. DNS domain name? | IP Address
    3. Organization name? My Organization
    4. Administrator password? Use the password during installation | Choose new one
    5. Database backend to use? HDB
    6. Remove the database when slapd is purged? No
    7. Move old database? Yes
    8. Allow LDAPv2 protocol? No
  3. joe /etc/phpldapadmin/config.php (i’m using joe text editor, you may use the default text editor such vi)
    $servers->setValue('server','host',' | IP Address');
    $config->custom->appearance['hide_template_warning'] = true;

LDAP: Install PHPLDAPAdmin

  1. apt-get install libpam-ldap nscd | pkg-reconfigure ldap-auth-config
    1. LDAP server Uniform Resource Identifier: ldap://**Domain-Name-OR-IP-Address** ( Change the initial string from “ldapi:///” to “ldap://” before inputing your server’s information )
    2. Distinguished name of the search base: ( This should match the value you put in your LDAP server’s/etc/phpldapadmin/config.php file. )
    3. LDAP version to use: 3
    4. Make local root Database admin: Yes
    5. Does the LDAP database require login? No
    6. LDAP account for root: This should also match the value in your /etc/phpldapadmin/config.php
    7. LDAP root account password: LDAP-Root-Password
  2. joe /etc/nsswitch.conf – add ldap before compat for each passwd, group, shadow
  3. joe /etc/pam.d/common-session – add at the bottom: session required skel=/etc/skel umask=0022
  4. /etc/init.d/nscd restart
  5. Access to PHPLDAPAdmin:

LDAP: Setting up LDAP Groups & Users

  1. Go to
  2. Login DN: cn=admin,dc=domain,dc=com
  3. Login Password: Password configured during slapd configuration
  4. To do:
    1. Create an Generic: Organization Units named Users
    2. Create a Generic: Posix Group named groups
    3. Create one or more Generic: User Account (make sure it’s under ou=users)
    4. (Optional) Add users to groups by clicking a group & Add New Attribute. Select memberUid and click on Update Object at the bottom.


ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); 

$ldapconn = ldap_connect("")
    or die("Could not connect to LDAP server.");

$person = 'cn=username,ou=users,dc=domain,dc=com';
$password = 'password';

if ($ldapconn) {

    $ldapbind = ldap_bind($ldapconn, $person, $password);

    if ($ldapbind) {

    	$ldaptree = "ou=users,dc=domain,dc=com";
		$justthese = array("ou", "sn", "givenname");

		$result = ldap_search($ldapconn,$ldaptree,"givenName=$person",$justthese) or die ("Error in search query: ".ldap_error($ldapconn));

		$no = ldap_count_entries($ldapconn, $result);
		echo 'Count Entries: ' . $no . '<br>';

		$info = ldap_get_entries($ldapconn, $result);
		for ($i=0; $i<$info["count"]; $i++) 
			echo $info[$i]['givenname'][0] . ' (' . $info[$i]['mail'][0] . ')';
			echo '<hr>';

    } else {
        echo "LDAP bind ".$user." failed...";


Reference: Installing LDAP on Ubuntu 12.04

jQuery: Show Loading…

	url: '',
	success: function(result) {
	beforeSend: function() {
	complete: function() {

Foundation: Startup


Download Foundation and Foundation Icon.

<!doctype html>
<html class="no-js" lang="en">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Foundation | Welcome</title>
    <link rel="stylesheet" href="css/foundation.css" />
    <link rel="stylesheet" href="css/foundation-icons.css" />
    <link rel="stylesheet" href="css/learn.css" /><!-- Your own set CSS -->
    <script src="js/vendor/modernizr.js"></script>
    <!--[if lte IE 8]><script src=""></script><![endif]-->
    <!-- Layout Start -->
    <!-- Layout End -->
    <script src="js/vendor/jquery.js"></script>
    <script src="js/foundation.min.js"></script>

Python: Setting up in Windows 7



  1. Download latest 2.x at
  2. Set Environment path: C:Python27;C:Python27Libsite-packages;C:Python27Scripts;
  3. Install Setuptools:
    1. Download the script
    2. Open CMD
    3. Go to the script directory
    4. Run the script: python
    5. Exit once done (Ctrl + Z, then Enter)

Test your installation by open up CMD, and type in python. You should see something similar to the screen shot below.


Following are optional:

  1. Install pip: C:> easy_install pip
  2. Install the followng using pip
    1. Mechanize: C:> pip install mechanize
    2. BeatifulSoup4: C:> pip install beautifulsoup4
    3. CSVKIT: C:> pip install csvkit