Monthly Archives: February 2012

How to run the shell or bash scripts from php?

I have a bash script that I want to be run from php using a passthru function.
if you don’t need any output you can use shell_exec or exec without
escapeshellcmd function

$command=’/bin/bash /copy_images.sh ‘;
$escaped_command = escapeshellcmd($command);
passthru($escaped_command, $output);
print_r($output);
$output is returning the exit code that the php interpreter gives to the shell:
0 – successful execution of the program, this means that the script doesn’t work as expected on php side, but does on the unix box;
1 – file not found, run as root or use sudo to access via php;
2 – script completed successfully
127 –file not found;

My copy_images.sh script is

 #!/bin/sh
####################################
#Copy images
####################################
echo  | sudo -S cp -av /var/www/

Integrating Foreign Trained Professionals

Lionel Laroche Lecture: Networking Canadian Style – Integrating Foreign Trained Professionals (2008)

Course Description

 

This conference is for Internationally Educated Professionals (IEPs). It is meant to help you. In particular, it is meant to give you an opportunity to network, both with other IEPs and mainstream Canadians. In virtually all countries, including Canada, networking is an essential part of one’s professional life. What you know is important; whom you know is essential.(read more)

How to share CakePHP 2.1 core for multiple apps?

CakePHP 2.1  allows you to use one set of core files while maintaining multiple applications.
Make sure the host is pointing to the correct directory like /var/www/Sites/app/webroot/. Verify mod_rewrite is in fact on. Enable mod_rewrite with: a2enmod rewrite.
Set up the .htaccess files in the /var/www/Sites/app/ and the /var/www/Sites/app/webroot directories.
The directory /var/www/frameworks/cakephp2.1 contains the core.

1. Change the following constants in /var/www/Sites/index.php:

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
 //OLD: define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
   define('CAKE_CORE_INCLUDE_PATH', DS.'var'.DS.'www'.DS.'frameworks'.DS.'cakephp2.1'.DS.'lib');
	}

2. Do changes in /var/www/Sites/app/webroot/index.php:

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
  if (function_exists('ini_set')) {
 //ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
 ini_set('include_path', DS.'var'.DS.'www'.DS.'frameworks'.DS.'cakephp2.0.6'.DS.'lib'. PATH_SEPARATOR . ini_get('include_path'));
		}
.....

As you can find same goes for plugins and vendors folder.
You can have only one cake core but you must have one app folder (containing MVC) by site.

Happy Coding!