2)sudo port update outdated
3)sudo port install php5-pcntl
4)Try the following example
$pid = pcntl_fork();
if($pid) {
// parent process runs what is here
print "parent\n";
}
else {
// child process runs what is here
print "child\n";
}
?>
#! /bin/sh
#
# /etc/init.d/mountec2vol
#
# chkconfig: 234 20 50
# description: Assigns an EC2 EBS Volume to a device and mounts the device
#
# To add this as a service run:
# /sbin/chkconfig --add mountec2vol
#
# VARS
#
DEV="/dev/sdh"
MOUNT_POINT="/vol"
EC2_LOG='/var/log/ec2.log';
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.13/
export EC2_PRIVATE_KEY=/root/.ec2/pk.pem
export EC2_CERT=/root/.ec2/cert.pem
export EC2_HOME=/usr/local/src/ec2-api-tools-1.3-36506/
PATH=$PATH:$HOME/bin:$EC2_HOME/bin
MAX_TRIES=60
attach_ebs()
{
/bin/echo "=====================================" | tee -a $EC2_LOG
/bin/echo "Date: "`date` | tee -a $EC2_LOG;
/bin/echo "Attaching Elastic Block Store Volumes." | tee -a $EC2_LOG
ec2-attach-volume $VOL -i $INSTANCE -d $DEV 1>&2 2>>$EC2_LOG
CTR=0
while [ ! -e "$DEV" ]; do
/bin/sleep 1
CTR=`expr $CTR + 1`
if [ $CTR -eq $MAX_TRIES ]
then
/bin/echo "WARNING: Cannot attach volume $VOL to $DEV -- Giving up after $MAX_TRIES attempts" | tee -a $EC2_LOG
exit 1
fi
done
}
mount_ebs()
{
/bin/echo "Checking if $MOUNT_POINT is present" | tee -a $EC2_LOG
if [ ! -d $MOUNT_POINT ]; then
mkdir $MOUNT_POINT 1>&2 2>>$EC2_LOG
fi
/bin/echo "Mounting EBS to /vol " | tee -a $EC2_LOG
/bin/mount $DEV $MOUNT_POINT 1>&2 2>>$EC2_LOG
}
mount_mysql_dirs()
{
/bin/echo "Mounting mysql dirs" | tee -a $EC2_LOG
/bin/mount /etc/mysql/ 1>&2 2>>$EC2_LOG
/bin/mount /var/lib/mysql/ 1>&2 2>>$EC2_LOG
/bin/mount /var/log/mysql/ 1>&2 2>>$EC2_LOG
/bin/mount /usr/local/nginx/ 1>&2 2>>$EC2_LOG
}
unmount_mysql_dirs()
{
set +e;
/bin/echo "stopping mysql" | tee -a $EC2_LOG
/etc/init.d/mysql stop;
set -e;
/bin/echo "Unmounting mysql dirs" | tee -a $EC2_LOG
/bin/umount /etc/mysql/ 1>&2 2>>$EC2_LOG
/bin/umount /var/lib/mysql/ 1>&2 2>>$EC2_LOG
/bin/umount /var/log/mysql/ 1>&2 2>>$EC2_LOG
}
unmount_nginx_dirs()
{
set +e;
/bin/echo "stopping nginx" | tee -a $EC2_LOG
/etc/init.d/nginx stop;
set -e;
/bin/echo "Unmounting nginx dirs" | tee -a $EC2_LOG
/bin/umount /usr/local/nginx/ 1>&2 2>>$EC2_LOG
}
unmount_ebs()
{
/bin/echo "Unmounting Elastic Block Store Volumes." | tee -a $EC2_LOG
/bin/umount $MOUNT_POINT 1>&2 2>>$EC2_LOG
}
detach_ebs()
{
/bin/echo "Detaching Elastic Block Store Volumes." | tee -a $EC2_LOG
ec2-detach-volume $VOL 1>&2 2>>$EC2_LOG
}
populate_aws_data()
{
/bin/echo "Populating AWS data" | tee -a $EC2_LOG
INSTANCE=`curl http://169.254.169.254/latest/meta-data/instance-id 2> /dev/null`
USERDATA=`curl http://169.254.169.254/1.0/user-data 2>/dev/null`;
}
parse_user_args()
{
/bin/echo "Parsing user_args " | tee -a $EC2_LOG
VOL=${USERDATA%|*};
IP=${USERDATA#*|};
echo "usedata vol ip";
echo $USERDATA;
echo $VOL;
echo $IP;
}
bind_ip()
{
/bin/echo "Associating ip address: $IP to $INSTANCE" | tee -a $EC2_LOG
ec2-associate-address -i $INSTANCE $IP;
}
# start/stop functions for OS
case "$1" in
start)
populate_aws_data;
parse_user_args;
bind_ip;
attach_ebs;
mount_ebs;
mount_mysql_dirs;
sh -x /vol/ec2_stuff/everytime_by_mountec2.sh;
;;
stop)
unmount_mysql_dirs;
unmount_nginx_dirs;
unmount_ebs;
detach_ebs;
;;
restart)
set +e;
$SELF stop;
set -e;
sleep 60;
$SELF start
;;
*)
echo "Usage: $0 {start|stop|restart}" | tee -a $EC2_LOG
exit 1
esac
exit 0
//to start Console
$ java -classpath ./bsh-2.0b4.jar bsh.Console
//to start Interpreter
$ java -classpath ./bsh-2.0b4.jar bsh.Interpreter
bsh % import java.io.Decoder;
bsh % String dir = "%2Fhome%2Fcodeshepherd";
bsh % System.out.println(dir);
%2Fhome%2Fcodeshepherd
bsh % System.out.println(Decoder.decode(dir));
/home/codeshepherd
Prelude> :t map
map :: (a -> b) -> [a] -> [b]
Prelude> let bar a = map (*1) a
Prelude> :t bar
bar :: (Num a) => [a] -> [a].
#ElizaLovesYou v0.4
#Changes
#Ported v0.3 to Pidgin by Deepan Chakravarthy
#Email: codeshepherd AT gmail DOT com
#Thanks to sadrul and resiak on #pidgin@irc.freenode.net and Davo_Dinkum on ##English@irc.freenode.net for their help.
#ElizaLovesYou v0.3 - Rogerian psychotherapist for Pidgin
#Copyright (C) 2004 Scott Wolchok
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#(You can find the GPL at http://www.gnu.org/copyleft/gpl.html)
#You'll need to install Chatbot::Eliza from CPAN before this will work.
#Run 'perl -MCPAN -e "shell"' and answer the questions, then type
#'install Chatbot::Eliza' at the prompt. That should do it!
#'install Pidgin' at the prompt
#'install Purple' at the prompt
#Please note that this plugin is just a hook for the Perl Chatbot::Eliza
#module - the credit for the actual "bot" goes to the John Nolan, the
#writer of that module.
#Superdug is great!!!!
use Pidgin;
use Purple;
use Chatbot::Eliza;
use strict;
my %bots;
my $plugin;
my $data = "";
#my @timeouts; #Pidgin segfaults if we leave the send_message timeout and unload the plugin
%::PLUGIN_INFO = (
perl_api_version => 2,
name => "ElizaLovesYou",
version => "0.4",
summary => "Rogerian psychotherapist for Pidgin",
description => "Automatically responds to incoming messages on all accounts using the Eliza algorithm",
author => "Scott Wolchok ",
url => "www.codeshepherd.com/downloads/elizalovesyou.pl",
load => "plugin_load",
unload => "plugin_unload"
);
sub plugin_init
{
return %::PLUGIN_INFO;
}
sub do_eliza
{
my $im;
my ($account, $sender, $message, $conv, $flags) = @_;
$bots{$sender} = new Chatbot::Eliza unless $bots{$sender};
while($message =~ s/<.*?>//)
{
}; #HTML si t3h sux0r!
if($conv)
{
my $theIM = $conv->get_im_data();
#Tried to use a queue to hold timeouts so we could remove them at plugin_unload - the thing segfaults if there's a timeout pending and you unload it
# push @timeouts, Pidgin::timeout_add($plugin,10,\&send_message,[$theIM,$bots{$sender}->transform($message)]);
Purple::timeout_add($plugin,1,\&send_message,[$theIM,$bots{$sender}->transform($message)]);
Purple::Debug::info($::PLUGIN_INFO{name}, "tutorialpluginLeaving do_eliza\n");
}
else
{
$conv = Purple::Conversation->new(1, $account, $sender);
if ($conv)
{
print "ok.\n";
$im = $conv->get_im_data();
# Here we send messages to the conversation
$im->send("Hi $sender, The maniac is sleeping or eating or buzy doing some shit!!!.");
$im->send("I am his dumb slave bot :). You can speak to me if you want!!!");
}
else
{
}
}
}
sub send_message
{
Purple::Debug::info($::PLUGIN_INFO{name}, "tutorialpluginEntering send_message\n");
my ($IM, $message) = @{$_[0]};
Purple::Debug::info($::PLUGIN_INFO{name}, "Shifting timeouts\n");
#shift @timeouts;
Purple::Debug::info($::PLUGIN_INFO{name}, "tutorialpluginSending message\n");
Purple::Conversation::IM::send($IM,$message);
return undef;
}
sub plugin_load
{
$plugin = shift;
my $conversations_handle = Purple::Conversations::get_handle();
Purple::Signal::connect($conversations_handle, "received-im-msg", $plugin, \&do_eliza, $data);
}
sub plugin_unload
{
my $plugin = shift;
# for my $timeout (@timeouts) {
# Pidgin::timeout_remove($timeout);
# }
}
#Note: I got this from forsaken in #gaim on FreeNode and renamed it to getIM, his original credit follows:
#From Split.pl and edited.
#Michael Wozniak and Anthony Noto
sub getIM
{
my $thing = $_[0];
my @im_array = Purple::ims(); #get the array of IM's
foreach my $element (@im_array)
{
if ( Purple::Conversation::get_name( Purple::Conversation::IM::get_conversation ( $element ) ) eq $thing )
{
return $element; #return the correct IM
}
}
return undef;
}
for(var i=0;i<1000;i++)
{
go("http://orkut.com")
enter("Email","myemail@gmail.com")
enter("password","secret")
sleep(600)
click("sign in")
sleep(600)
go("http://www.orkut.com/GLogin.aspx?cmd=logout")
sleep(60)
}