Agent
view release on metacpan or search on metacpan
--------------------
If you don't have a make utility, try setting your PERL5LIB environment
variable to point to the Agent Perl distribution. If that doesn't work, try
copying all of the .pm files into your site-perl directory, making sure to
keep the directory structure intact.
Anyone willing to compile a PPM for Agent Perl is more than welcome!
Please read the README file before you start to play :-).
+---
Steve Purkis <spurkis@engsoc.carleton.ca>
October 30, 1998
Platforms:
U*nix & Win32
Mac? OS/2?
Using Agents
------------
First of all, make sure you know how to use an object (the perlobj manpage is
a good place to start). Then read the Agent.pm's POD, and that of the agent
you are trying to use. After that, you're on your own, unless there are any
examples lying around :-).
If you would like to use the security features of Agent Perl, browse through
the Safe and Opcode PODs, and have a gander at 'Safe.readme'.
Developing Agents
-----------------
examples/Loop.pa view on Meta::CPAN
sub agent_main {
my ($self, @args) = @_;
# first, get a Transport address:
my $tcp = new Agent::Transport(
Medium => 'TCP',
Cycle => 1
) or die "Couldn't get a tcp transport address: $!!\n";
print "Got tcp address: " . $tcp->address . "\n" if $self->{verbose};
# start the message...
my $msg = new Agent::Message(
Body => [ $tcp->address . "\n", 'hi' ]
);
print "Started Loop agent.\n";
# should we start the loop, or wait for the remote to start?
if ($self->{Tell}) {
print "Initiating loop...\n";
$msg->add_dest( 'TCP', $self->{Tell} ) or die "Error: $!\n";
unless ($msg->send) {
print "Couldn't send message!\n";
return;
}
}
while (1) { # loop till user/remote breaks
examples/README view on Meta::CPAN
-------------------
Copyright (c) 1997, 1998 Steve Purkis. All rights reserved. This software
is free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
There are now 5 example agents distributed with Agent Perl:
* the Loop agent - repeatedly sends the message 'hi' to another loop
agent. This one can be invoked in one of two ways: as an initiator
or as a reciever. An initiator starts the loop, while a reciever
waits for the loop to be started.
* the Static agent - allows an agent to execute on the host machine.
Acts as an 'agent server' of sorts.
* the HelloWorld agent - transports itself to a remote address, and
attempts to print 'Hello World' on the remote screen.
* the FreeSpace agent - transports itself to a remote addresses, and
attempts to find out how much space is free on each host,
printing a summary on the last host it reaches.
examples/dcalc.pl view on Meta::CPAN
# safe to say it's an ip address
if ($args{Return}) { $hosts{$arg} = ''; }
else { $args{Return} = $arg; }
} elsif ($arg =~ /-v/i) {
$args{'verbose'} = 1;
} elsif ($arg =~ /-t/i) {
$args{'Thread'} = 1;
}
}
unless ((keys(%hosts)) > 0) { print $usage; exit 1; }
print "starting distributed calculation agent system.\n";
# get a TCP transport address:
my $tcp = new Agent::Transport(
Medium => 'TCP',
Address => $args{Return}
) or die "Couldn't get a tcp transport address: $!!\n";
$args{Return} = $tcp->address();
print "Got tcp address $args{Return}.\n" if $args{verbose};
examples/ex.pl view on Meta::CPAN
[a1.b1.c1.d1:port1 [a2.b2.c2.d2:port2 ...]]
-v = verbose mode
-s = use a Safe compartment for each agent run [Static only]
-t = use Thread.pm [if available. Static only]
-l = redirect STDOUT to the logfile specified
aN.bN.cN.dN:portN
= numeric ip address and port of remote agent to talk to,
or address to listen on if Static agent.
For example, this starts a Safe Static agent in quiet mode:
perl ex.pl -n Static -s 192.168.0.53:24368
USAGE
# if you want to see lots of meaningless output :-), uncomment these:
$Agent::Message::Debug = 1;
$Agent::Transport::TCP::Debug = 1;
$Agent::Debug = 1;
#$Class::Tom::debug = 1;
( run in 0.591 second using v1.01-cache-2.11-cpan-0d8aa00de5b )