I am using NET::SSH::Perl. Login is correct. mkdir is correct. Yet when I
try to pass a local file to remote host to copy file to newly created
directory, it fails:
code:
use Net::SSH::Perl
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
print $ssh->cmd("mkdir $site);
print $ssh->cmd("cd $site); #does not change directory tested using
"cmd("pwd")"
print $ssh->cmd("cp $filename");
etc...
Any help would help.
thanks in advance
Richard
-----Original Message-----
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 07, 2003 3:44 PM
To: [EMAIL PROTECTED]
Subject: Re: Holding File handles in a {} anonymous hash
Dan Anderson wrote:
> I have a module that works with a couple of different file handles. Is
> it possible to hide them within an anonymous hash? {} (i.e. the objects
> data). Right now I have:
>
> if (condition_is_met()) {
> open("FILE","<file");
> }
>
> This is in the main body of my package (and thus, I assume, accessible
> by all functions). Is it better to use tighter encapsulation (i.e. a
> closure or throwing it into an anonymous hash) or just to leave it in
> the body?
I think you'd be safe like this, except that if you have a lot of them
then you dont' know what the filehandle is going to be called. Here
you've used *Package::FILE, but there's no general way of getting to
that package name from any given filename. How about a hash of glob
references?
Here's a closure with a subroutine which keeps a list of handles for
each file it has already opened. The program just uses it to print
the next line from alternate files.
I hope this helps.
Rob
use strict;
use warnings;
line_from ('filea');
line_from ('fileb');
line_from ('filea');
line_from ('fileb');
line_from ('filea');
line_from ('fileb');
{
my %filehandle;
my $fh;
sub line_from {
my $file = shift;
$fh = $filehandle{$file};
unless (defined $fh) {
open $fh, $file or die $!;
$filehandle{$file} = $fh;
}
print scalar <$fh>;
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]