Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
more useful options
 
PerlMonks

POE::Component::RemoteTail - Can't locate object method new

by cmv (Hermit)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

on Feb 24, 2009 at 16:26 UTC ( #746039=perlquestion: print w/ replies, xml ) Need Help??
cmv has asked for the wisdom of the Perl Monks concerning the following question:

Objectwize Monks-

I'm trying to learn the musty innards of POE::Component::RemoteTail, and have successfully run a modified version example program listed in the documentation.

use strict; use warnings; use Data::Dumper; use POE; # This should be added to the docs... use POE::Component::RemoteTail; my ( $host, $path, $user ) = (qw(myhost.domain.com /home/mylogin/.profile mylogin)); my $alias = 'Remote_Tail'; # spawn component my $tailer = POE::Component::RemoteTail->spawn( alias=>$alias ); # create job my $job = $tailer->job( host=>$host, path=>$path, user=>$user, ); # prepare the postback subroutine at main POE session POE::Session->create( inline_states=>{ _start=>sub { my ( $kernel, $session ) = @_[ KERNEL, SESSION ]; # create postback my $postback = $session->postback("MyPostback"); # post to execute $kernel->post( $alias, "start_tail"=>{ job=>$job, postback=>$postback } ); }, # return to here MyPostback=>sub { my ( $kernel, $session, $data ) = @_[ KERNEL, SESSION, ARG1 ]; print STDERR "DATA DUMP:\n", Dumper($data), "\n"; }, }, ); POE::Kernel->run();
Now, I'm trying to follow the docs to run the (slightly modified) example script (see readmore below) to use the NetSSHPerl custom engine with this module, that is described in POE::Component::RemoteTail::Engine::NetSSHPerl, and I keep getting the error:

Can't locate object method "new" via package "POE::Component::RemoteTail::CustomEngine::NetSSHPerl" at lib/POE/Component/Remotetail.pm line 102.

I'm suspecting that the object stuff isn't setup correctly in the RemoteTail/CustomEngine/NetSSHPerl.pm file, but I don't know enough to fix it.

use strict; use warnings; use POE; use POE::Component::Remotetail; my ( $host, $path, $user ) = (qw(myhost.domain.com /home/mylogin/.profile mylogin)); my $tailer = POE::Component::RemoteTail->spawn(); my $job = $tailer->job( host => $host, path => $path, user => $user, process_class => "POE::Component::RemoteTail::CustomEngine::NetS +SHPerl" ); POE::Session->create( inline_states => { _start => sub { my $kernel = $_[KERNEL]; $kernel->post($tailer->session_id(), "start_tail" => {jo +b => $job}); $kernel->delay_add("stop_job", 100); }, stop_job => sub { my $kernel = $_[KERNEL]; $kernel->post($tailer->session_id(), "stop_tail" => {job + => $job}); } } ); POE::Kernel->run();
Any help is very much appreciated!

Thanks

-Craig

Comment on POE::Component::RemoteTail - Can't locate object method new
Select or Download Code
Re: POE::Component::RemoteTail - Can't locate object method new
by rcaputo (Hermit) on Feb 24, 2009 at 17:01 UTC

    If you've correctly spelled "POE::Component::RemoteTail::CustomEngine::NetSSHPerl", then it appears you haven't loaded that module. Will POE::Component::RemoteTail automatically use() it for you? I didn't see that mentioned in a quick skim of the docs....

      Rocco-

      Will POE::Component::RemoteTail automatically use() it for you?

      I think so, here's a code excerpt from RemoteTail.pm:

      102 # use custom class 103 if ( my $class = $job->{process_class} ) { 104 $class->require or die(@!); 105 $class->new(); 106 %program = ( Program => sub { $class->process_entry($j +ob) }, ); 107 }
      Also, I added a print statement to the beginning of the NetSSHPerl module, and I saw the print output before the error message came out.

      I'm also confused because I don't understand the meat of the RemoteTail::CustomEngine::NetSSHPerl module:

      use POE::Component::RemoteTail::CustomEngine::NetSSHPerl; use strict; use warnings; use Net::SSH::Perl; print STDERR "In NetSSHPerl...\n"; #Added by cmv sub process_entry { my $self = shift; my $arg = shift; my $host = $arg->{host}; my $path = $arg->{path}; my $user = $arg->{user}; my $password = $arg->{password}; my $cmd = "tail -f $path"; my $ssh = Net::SSH::Perl->new( $host, protocol => "2,1" ); $ssh->login($user); $ssh->register_handler( "stdout", sub { my ( $channel, $buffer ) = @_; my $log = $buffer->bytes; print $log; unless ($log) { exit; } } ); my ( $stdout, $stderr, $exit ) = $ssh->cmd($cmd); } 1;
      Why does it have a use statement pointing to itself?
      Shouldn't it have a module declaration instead?

      I'm confused.

        That does look bizarre. Off the top of my head, I would expect the use statement to be package and perhaps it's missing a use base pragma.

        This module seems to need some love. Maybe the author would be willing to heap some on it if they knew someone was trying to use it?

POE::Component::RemoteTail - Additional Suggested Enhancements
by cmv (Hermit) on Feb 24, 2009 at 19:02 UTC
    As I'm delving deeper into this module, I'm finding various situations that the module running the standard ssh command, doesn't address too well. I'm planning on provide the author with code modification suggestions.

    -Hangs on exec errors (ssh isn't in path or executable). I think this is due to not closing the POE wheel properly (Rocco?).
    -No warnings or errors are currently being printed out on exec errors.
    -No way to add command line options to the ssh command to be run
    -Needs expanded debug statements.

    Please add to this thread any additional issues you may find, and I'll try to condense it into a group of suggestions for the author.

    Thanks

    -Craig

    Update:
    -The existing Net::SSH::Perl custom engine will only work with SSH protocol 2 as written.

      Hi! My name is Takeshi Miki, author of POE::Component::RemoteTail.

      Thank you for your suggestions.
      I uploaded the version of improved ones to CPAN a moment ago. I was not able to apply all of your suggestion, but lost the clear bug.

      Check it out and enjoy!

      thanks.

Login:
Password
remember me
What's my password?
Create A New User

Node Status?
node history
Node Type: perlquestion [id://746039]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (24)
Fletch
ww
jdporter
FunkyMonk
holli
Gavin
atcroft
Khen1950fx
jethro
kennethk
thezip
Eyck
tsee
LanX
pemungkah
5mi11er
roho
ssandv
je44ery
molecules
MikeDexter
perly_newbie
AriSoft
im2
As of 2010-02-09 22:40 GMT
Sections?
The Monastery Gates
Seekers of Perl Wisdom
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Cool Uses for Perl
Perl News
Information?
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes?
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers?
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth?

What level of existential comfort do you require?

Palace
Executive suite at the best hotel
Regular hotel in a decent part of town
Motel
Boarding house
Sleeping Bag on Couch in Basement
Any port in a storm
Camping under the freeway overpass
Jail
Other

Results (283 votes), past polls