GRID::Machine::Result - The object describing the result of a GRID::Machine RPC


GRID-Machine documentation  | view source Contained in the GRID-Machine distribution.

Index


NAME

Top

GRID::Machine::Result - The object describing the result of a GRID::Machine RPC

DESCRIPTION

Top

The class GRID::Machine::Result is used by both the local and remote sides of the GRID::Machine, though most of its methods are called on the remote side.

The result of a RPC is a GRID::Machine::Result object. Such object has the following attributes:

* type

The type of result returned. A string. Fixed by the protocol. Common values are RETURNED and DIED.

* stdout

A string containing the contents of STDOUT produced during the duration of the RPC

* stderr

A string containing the contents of STDERR produced during the duration of the RPC

* results

A reference to an ARRAY containing the results returned by the RPC

* errcode

The contents of $? as produced during the RPC

* errmsg

The contents of $@ as produced during the RPC

The Constructor new

Syntax:

  GRID::Machine::Result->new(
    stdout => $rstdout, 
    errmsg  => $err, 
    stderr => $rstderr, 
    results => \@results
  )

Builds a new result object.

The ok Method

Returns TRUE if the RPC didn't died, i.e. if the type attribute is not the string 'DIED'

The noerr Method

Returns TRUE if the RPC didn't died and didn't send any messages through stderr. See an example. When running the following program:

  $ cat noerrvsok.pl
  #!/usr/local/bin/perl -w
  use strict;
  use GRID::Machine;

  my $machine = shift || $ENV{GRID_REMOTE_MACHINE};
  my $m = GRID::Machine->new( host => $machine );

  my $r = $m->eval( q{print STDERR "This is the end\n" });

  print "print to STDERR:\n";
  print "<".$r->ok.">\n";
  print "<".$r->noerr.">\n";

  $r = $m->eval( q{warn "This is a warning\n" });

  print "Warn:\n";
  print "<".$r->ok.">\n";
  print "<".$r->noerr.">\n";

we get the following output:






                $ errvsok.pl
                print to STDERR:
                <1>
                <>
                Warn:
                <1>
                <>

The result Method

Returns the first element of the list referenced by the results attribute This method is called when a GRID::Machine::Result object is evaluated in a Boolean context (i.e. bool is overloaded).

The Results Method

Returns the list referenced by the results attribute

The str Method. Stringification of a Result object

Returns the string made of concatenating stdout, stderr and errmsg. The Perl operator q("") is overloaded using this method. Thus, wherever a GRID::Machine::Result object is used on a scalar string context the str will be called.

SEE ALSO

Top

* GRID::Machine
* GRID::Machine::IOHandle
* GRID::Machine::Group
* GRID::Machine::Process
* GRID::Machine::perlparintro
* Net::OpenSSH
* IPC::PerlSSH
* IPC::PerlSSH::Async
* Man pages of ssh, ssh-key-gen, ssh_config, scp, ssh-agent, ssh-add, sshd
* http://www.openssh.com

AUTHOR

Top

Casiano Rodriguez Leon <casiano@ull.es>

ACKNOWLEDGMENTS

Top

This work has been supported by CEE (FEDER) and the Spanish Ministry of Educacion y Ciencia through Plan Nacional I+D+I number TIN2005-08818-C04-04 (ULL::OPLINK project http://www.oplink.ull.es/). Support from Gobierno de Canarias was through GC02210601 (Grupos Consolidados). The University of La Laguna has also supported my work in many ways and for many years.

I wish to thank Paul Evans for his IPC::PerlSSH module: it was the source of inspiration for this module. To Alex White, Dmitri Kargapolov, Eric Busto and Erik Welch for their contributions. To the Perl Monks, and the Perl Community for generously sharing their knowledge. Finally, thanks to Juana, Coro and my students at La Laguna.

LICENCE AND COPYRIGHT

Top


GRID-Machine documentation  | view source Contained in the GRID-Machine distribution.