Code I wrote to do most of what you people are talking about a couple of
weeks back, loading over ssh.

This does not work for non-pure perl code.  i.e. XS is a no-no

The idea I was using it for:

 a) User presses a button in the web browser
 b) Downloads .config.html from that directory the site which contains 

    i)  The current directory from the server's point of view
    ii) The address of the perl code to configure this site

    Both of which have RC5 checksums    

 c) The perl code is downloaded to configure said site and run  This
    starts a Tk widget that can be used to edit config stuff remotely.

The key idea behind this is that you need nothing special on the server
bar ssh and httpd.  And your client need have no special idea of what
it needs to have installed.

Anyway, the code:

use File::Remote;

# then later

######################################################################## 
# Setting up the @INC trap
########################################################################

    # right now we modify @INC so that it will load files from afar
    # this stolen from p5p - http://www.perl.com/pub/2001/03/
    # p5pdigest/THISWEEK-20010305.html

    push @INC, sub 
    {
        my $foo = shift;
        my $modname = shift;
              
        # this is going through scp - make all :: into /
        $modname =~ s|::|/|;

        # combine the paths
        my $filename = $codepath.$modname;

        # create a $remote object
        my $remote = File::Remote->new( rsh => '/usr/bin/ssh',
                                   rcp => '/usr/bin/scp',); 

        my $fh = new IO::Handle;

        # open the thingy as if by magic, returning
        # undef if there is a problem
        $remote->open($fh, $filename) or return undef;

        return $fh;
   }


-- 
print "\n",map{my$a="\n"if(length$_>6);' 'x(36-length($_)/2)."$_\n$a"} (
   Name  => 'Mark Fowler',        Title => 'Technology Developer'      ,
   Firm  => 'Profero Ltd',        Web   => 'http://www.profero.com/'   ,
   Email => '[EMAIL PROTECTED]',   Phone => '+44 (0) 20 7700 9960'      )





Reply via email to