[28868] in Perl-Users-Digest
Perl-Users Digest, Issue: 112 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 9 22:46:12 2007
Date: Fri, 9 Feb 2007 19:45:37 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 9 Feb 2007 Volume: 11 Number: 112
Today's topics:
Multiple Line Extraction <doni.sekar@gmail.com>
Re: Multiple Line Extraction <someone@example.com>
Re: Multiple Line Extraction <attn.steven.kuo@gmail.com>
Re: Multiple Line Extraction <doni.sekar@gmail.com>
Re: Multiple Line Extraction <DJStunks@gmail.com>
Net::SSH::Perl - Channel open failure? <CSB001@gmail.com>
Re: Net::SSH::Perl - Channel open failure? (NOSPAM)
Re: Net::SSH::Perl - Channel open failure? <CSB001@gmail.com>
Re: Net::SSH::Perl - Channel open failure? (NOSPAM)
Re: Net::SSH::Perl - Channel open failure? <zentara@highstream.net>
Re: Net::SSH::Perl - Channel open failure? <CSB001@gmail.com>
Re: Net::SSH::Perl - Channel open failure? <CSB001@gmail.com>
Re: Net::SSH::Perl - Channel open failure? <raherh@gmail.com>
Re: Net::SSH::Perl - Channel open failure? <raherh@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Feb 2007 12:23:18 -0800
From: "doni" <doni.sekar@gmail.com>
Subject: Multiple Line Extraction
Message-Id: <1170793398.925885.305060@k78g2000cwa.googlegroups.com>
Hi,
I was wondering how can I read two lines from a file at a time and
extract the data from the first line and second line onto different
variables.
Below is the data snippet that I am using to write my program. The
data contains the path information extracted from each node. The node
value which occurs at the beginning of the next line after "from" line
is the one whose path information we are extracting.
If the line does not contain "from" field at the beginning, I want to
read 2 lines and extract the contents of the first line and second
line onto different fields before we iterate through the while loop .
If the line contains "from" field read the line and iterate through
the while loop to read the next line from the file.
from to reachable rssi
08:c0 09:c3 yes 3
09:c3 08:c0 yes 2
08:c0 09:c4 yes 7
09:c4 08:c0 yes 7
08:c0 09:c8 yes 3
09:c8 08:c0 yes 3
08:c0 09:d8 no 8
09:d8 08:c0 no 7
from to reachable rssi
09:c3 08:22 yes 15
08:22 09:c3 yes 10
09:c3 08:c0 yes 2
08:c0 09:c3 yes 3
09:c3 09:c4 no 4
09:c4 09:c3 no 8
from to reachable rssi
09:c4 08:c0 yes 7
08:c0 09:c4 yes 7
09:c4 09:c3 no 8
09:c3 09:c4 no 4
09:c4 09:c8 yes 7
09:c8 09:c4 yes 7
from to reachable rssi
09:c8 08:c0 yes 3
08:c0 09:c8 yes 3
09:c8 09:c4 yes 7
09:c4 09:c8 yes 7
09:c8 09:d8 yes 6
09:d8 09:c8 yes 6
from to reachable rssi
09:d8 08:22 yes 4
08:22 09:d8 yes 7
09:d8 08:c0 no 7
08:c0 09:d8 no 8
09:d8 09:c8 yes 6
09:c8 09:d8 yes 6
Here is the code I wrote to perform the above operation.
#! /usr/bin/perl
use strict;
use warnings;
my $ex_data = 'routed_info';
open (NETSTAT,$ex_data) || die("Cannot Open File: $!");
my $route_node; my $rssi;
my @mac_id;
my $first_node; my $second_node;
my $first_rssi; my $second_rssi;
my $first_link; my $second_link;
while (<NETSTAT>) {
chomp;
my @words = split;
if (/^([a-z]+)\s+([a-z]+)\s+([a-z]+)\s+([a-z]+)/) {
$route_node = 1;
}
elsif ($route_node == 1) {
push (@mac_id, $words[0]);
$route_node = 0;
$first_node = $words[1]; $first_link = $words[2]; $first_rssi
= $words[3];
next <NETSTAT>;
$second_link = $words[2]; $second_rssi = $words[3];
if (($first_link eq "yes") && ($second_link eq "yes")) {
$rssi = ($first_rssi + $second_rssi)/2;
print "Combined RSSI value from $words[1] and
$first_node is: $rssi\n";
}
}
else {
}
}
close(NETSTAT) || die("Cannot close $ex_data: $!");
Pls, let me know If I I havent clearly described my issue here. Can
anyone let me know how can I perform this.
Thanks,
doni
------------------------------
Date: Tue, 06 Feb 2007 22:33:17 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Multiple Line Extraction
Message-Id: <Nm7yh.40844$Y6.176@edtnps89>
doni wrote:
>
> I was wondering how can I read two lines from a file at a time and
> extract the data from the first line and second line onto different
> variables.
>
> Below is the data snippet that I am using to write my program. The
> data contains the path information extracted from each node. The node
> value which occurs at the beginning of the next line after "from" line
> is the one whose path information we are extracting.
>
> If the line does not contain "from" field at the beginning, I want to
> read 2 lines and extract the contents of the first line and second
> line onto different fields before we iterate through the while loop .
> If the line contains "from" field read the line and iterate through
> the while loop to read the next line from the file.
>
> from to reachable rssi
> 08:c0 09:c3 yes 3
> 09:c3 08:c0 yes 2
>
> [ SNIP ]
>
> 09:d8 09:c8 yes 6
> 09:c8 09:d8 yes 6
>
>
> Here is the code I wrote to perform the above operation.
>
>
> #! /usr/bin/perl
>
> use strict;
> use warnings;
>
> my $ex_data = 'routed_info';
> open (NETSTAT,$ex_data) || die("Cannot Open File: $!");
>
> my $route_node; my $rssi;
> my @mac_id;
> my $first_node; my $second_node;
> my $first_rssi; my $second_rssi;
> my $first_link; my $second_link;
>
> while (<NETSTAT>) {
> chomp;
> my @words = split;
> if (/^([a-z]+)\s+([a-z]+)\s+([a-z]+)\s+([a-z]+)/) {
> $route_node = 1;
> }
> elsif ($route_node == 1) {
> push (@mac_id, $words[0]);
> $route_node = 0;
> $first_node = $words[1]; $first_link = $words[2]; $first_rssi
> = $words[3];
> next <NETSTAT>;
> $second_link = $words[2]; $second_rssi = $words[3];
> if (($first_link eq "yes") && ($second_link eq "yes")) {
> $rssi = ($first_rssi + $second_rssi)/2;
> print "Combined RSSI value from $words[1] and
> $first_node is: $rssi\n";
> }
>
> }
> else {
> }
> }
> close(NETSTAT) || die("Cannot close $ex_data: $!");
>
>
> Pls, let me know If I I havent clearly described my issue here. Can
> anyone let me know how can I perform this.
It looks like this is close to what you want:
#!/usr/bin/perl
use warnings;
use strict;
my $ex_data = 'routed_info';
open NETSTAT, '<', $ex_data or die "Cannot Open '$ex_data' $!";
my $flag;
my %data;
while ( <NETSTAT> ) {
next unless /^ ([[:xdigit:]]{2}:[[:xdigit:]]{2})
\s+
([[:xdigit:]]{2}:[[:xdigit:]]{2})
\s+
(yes|no)
\s+
(\d+)
/x;
my $key = join ' and ', ++$flag & 1 ? ( $1, $2 ) : ( $2, $1 );
$data{ $key }{ reachable } .= $3;
$data{ $key }{ rssi } += $4;
next unless $data{ $key }{ reachable } eq 'yesyes';
print "Combined RSSI value from $key is: ", $data{ $key }{ rssi } / 2, "\n";
%data = ();
}
__END__
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: 6 Feb 2007 15:32:25 -0800
From: "attn.steven.kuo@gmail.com" <attn.steven.kuo@gmail.com>
Subject: Re: Multiple Line Extraction
Message-Id: <1170804745.428628.18330@a75g2000cwd.googlegroups.com>
On Feb 6, 12:23 pm, "doni" <doni.se...@gmail.com> wrote:
> Hi,
>
> I was wondering how can I read two lines from a file at a time and
> extract the data from the first line and second line onto different
> variables.
>
> Below is the data snippet that I am using to write my program. The
> data contains the path information extracted from each node. The node
> value which occurs at the beginning of the next line after "from" line
> is the one whose path information we are extracting.
>
> If the line does not contain "from" field at the beginning, I want to
> read 2 lines and extract the contents of the first line and second
> line onto different fields before we iterate through the while loop .
> If the line contains "from" field read the line and iterate through
> the while loop to read the next line from the file.
(snipped)
You might find the natatime function from List::MoreUtils useful:
use List::MoreUtils qw/natatime/;
use constant {
FROM => 0,
TO => 1,
REACHABLE => 2,
RSSI => 3,
};
my @netstat = grep !/^from/, <DATA>;
my $iterator = natatime 2, @netstat;
while (my @pair = map { [ split ] } $iterator->())
{
if ($pair[0][REACHABLE] eq 'yes' and $pair[1][REACHABLE] eq 'yes')
{
print "$pair[0][FROM] $pair[0][TO] = ",
($pair[0][RSSI] + $pair[1][RSSI])/2,
"\n";
}
}
__DATA__
from to reachable rssi
08:c0 09:c3 yes 3
09:c3 08:c0 yes 2
08:c0 09:c4 yes 7
09:c4 08:c0 yes 7
08:c0 09:c8 yes 3
09:c8 08:c0 yes 3
08:c0 09:d8 no 8
09:d8 08:c0 no 7
--
Hope this helps,
Steven
------------------------------
Date: 6 Feb 2007 15:52:55 -0800
From: "doni" <doni.sekar@gmail.com>
Subject: Re: Multiple Line Extraction
Message-Id: <1170805975.872829.280460@q2g2000cwa.googlegroups.com>
On Feb 6, 2:33 pm, "John W. Krahn" <some...@example.com> wrote:
>
> while ( <NETSTAT> ) {
> next unless /^ ([[:xdigit:]]{2}:[[:xdigit:]]{2})
> \s+
> ([[:xdigit:]]{2}:[[:xdigit:]]{2})
> \s+
> (yes|no)
> \s+
> (\d+)
> /x;
I was wondering how does this matching operation works especially
[[:xdigit:]]{2} in this above statement.
Also, can you explain me how this below statement works as I couldnt
understand how you extract the data from the 2 lines.
> my $key = join ' and ', ++$flag & 1 ? ( $1, $2 ) : ( $2, $1 );
>
> $data{ $key }{ reachable } .= $3;
> $data{ $key }{ rssi } += $4;
>
> next unless $data{ $key }{ reachable } eq 'yesyes';
>
> print "Combined RSSI value from $key is: ", $data{ $key }{ rssi } / 2, "\n";
>
Thanks,
doni
------------------------------
Date: 6 Feb 2007 16:07:01 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Multiple Line Extraction
Message-Id: <1170806821.243717.200370@k78g2000cwa.googlegroups.com>
On Feb 6, 4:32 pm, "attn.steven....@gmail.com"
<attn.steven....@gmail.com> wrote:
> On Feb 6, 12:23 pm, "doni" <doni.se...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I was wondering how can I read two lines from a file at a time and
> > extract the data from the first line and second line onto different
> > variables.
>
> > Below is the data snippet that I am using to write my program. The
> > data contains the path information extracted from each node. The node
> > value which occurs at the beginning of the next line after "from" line
> > is the one whose path information we are extracting.
>
> > If the line does not contain "from" field at the beginning, I want to
> > read 2 lines and extract the contents of the first line and second
> > line onto different fields before we iterate through the while loop .
> > If the line contains "from" field read the line and iterate through
> > the while loop to read the next line from the file.
>
> (snipped)
>
> You might find the natatime function from List::MoreUtils useful:
>
> use List::MoreUtils qw/natatime/;
>
> use constant {
> FROM => 0,
> TO => 1,
> REACHABLE => 2,
> RSSI => 3,
>
> };
>
> my @netstat = grep !/^from/, <DATA>;
> my $iterator = natatime 2, @netstat;
>
> while (my @pair = map { [ split ] } $iterator->())
> {
> if ($pair[0][REACHABLE] eq 'yes' and $pair[1][REACHABLE] eq 'yes')
> {
> print "$pair[0][FROM] $pair[0][TO] = ",
> ($pair[0][RSSI] + $pair[1][RSSI])/2,
> "\n";
> }
>
> }
>
> __DATA__
> from to reachable rssi
> 08:c0 09:c3 yes 3
> 09:c3 08:c0 yes 2
> 08:c0 09:c4 yes 7
> 09:c4 08:c0 yes 7
> 08:c0 09:c8 yes 3
> 09:c8 08:c0 yes 3
> 08:c0 09:d8 no 8
> 09:d8 08:c0 no 7
nice script, Steven. :-)
I might quibble with your K&R-style indentation, but I suppose I
won't :-)~
-jp
------------------------------
Date: 6 Feb 2007 08:33:08 -0800
From: "CsB" <CSB001@gmail.com>
Subject: Net::SSH::Perl - Channel open failure?
Message-Id: <1170779588.400710.56570@p10g2000cwp.googlegroups.com>
I am attempting to write a couple of test scripts to use SSH for
connecting to a host, executing commands, and displaying the results..
I've exhausted my google-fu (even Google code search) and hoped
someone might be able to enlighten me as to why this script is
failing.
I'm receiving "Channel open failure: 1: reason 1: open failed" in my
debug statements. From what I can tell, all this means is the SSH
Open was administratively prohibited (for any number of reasons).
What I'm confused about, though, is I connect to my test host using
SSH 2. And in the Net::SSH::Perl docs, it says "SSH-2 fuly supports
running more than one command over the same connection". However, in
my debug info (below) it looks like my script is attempting to open a
second connection (channel 1) for sending the command instead of using
the currently open connection (channel 0).
Is there something special I need to do to utilize the existing open
connection for subsequent commands? Or, am I way out in left-field on
ths problem?
Any suggestions or advice would be greatly appreciated.
- - BEGIN - SCRIPT - - - - - - - -
use Net::SSH::Perl;
use strict;
use warnings;
my $host = "example.host.com";
my $user = "username";
my $password = "password";
my $cmd = "ls";
my $ssh = Net::SSH::Perl->new(
$host,
debug => 1,
protocol => '2,1',
port => 22
);
$ssh->login( $user, $password );
$ssh->register_handler(
"stdout",
sub {
my ( $channel, $buffer ) = @_;
print "I received this: ", $buffer->bytes;
}
);
$ssh->cmd($cmd);
- - END - SCRIPT - - - - - - - -
- - BEGIN - OUTPUT - - - - - - - -
development[/home/user]# test-ssh.pl
development: Reading configuration data //.ssh/config
development: Reading configuration data /etc/ssh_config
development: Allocated local port 1021.
development: Connecting to example.host.com, port 22.
development: Remote version string: SSH-2.0-OpenSSH_2.9p2
development: Remote protocol version 2.0, remote software version
OpenSSH_2.9p2
development: Net::SSH::Perl Version 1.30, protocol version 2.0.
development: No compat match: OpenSSH_2.9p2.
development: Connection established.
development: Sent key-exchange init (KEXINIT), wait response.
development: Algorithms, c->s: 3des-cbc hmac-sha1 none
development: Algorithms, s->c: 3des-cbc hmac-sha1 none
development: Entering Diffie-Hellman Group 1 key exchange.
development: Sent DH public key, waiting for reply.
development: Received host key, type 'ssh-dss'.
development: Host 'example.host.com' is known and matches the host
key.
development: Computing shared secret key.
development: Verifying server signature.
development: Waiting for NEWKEYS message.
development: Enabling incoming encryption/MAC/compression.
development: Send NEWKEYS, enable outgoing encryption/MAC/compression.
development: Sending request for user-authentication service.
development: Service accepted: ssh-userauth.
development: Trying empty user-authentication request.
development: Authentication methods that can continue: keyboard-
interactive,password.
development: Next method to try is password.
development: Trying password authentication.
development: Login completed, opening dummy shell channel.
development: channel 0: new [client-session]
development: Requesting channel_open for channel 0.
development: channel 0: open confirm rwindow 0 rmax 16384
development: Got channel open confirmation, requesting shell.
development: Requesting service shell on channel 0.
development: channel 1: new [client-session]
development: Requesting channel_open for channel 1.
development: Entering interactive session.
development: Channel open failure: 1: reason 1: open failed
development[/home/user]#
- - END - OUTPUT - - - - - - - - - -
------------------------------
Date: Tue, 06 Feb 2007 14:39:12 -0600
From: "Mumia W. (NOSPAM)" <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Net::SSH::Perl - Channel open failure?
Message-Id: <eqaqql$7j3$1@aioe.org>
On 02/06/2007 10:33 AM, CsB wrote:
> I am attempting to write a couple of test scripts to use SSH for
> connecting to a host, executing commands, and displaying the results..
>
> I've exhausted my google-fu (even Google code search) and hoped
> someone might be able to enlighten me as to why this script is
> failing.
>
> I'm receiving "Channel open failure: 1: reason 1: open failed" in my
> debug statements. From what I can tell, all this means is the SSH
> Open was administratively prohibited (for any number of reasons).
> [...]
Maybe, maybe not. I advise against using Net::SSH::Perl. Others have
noted it to be buggy, and I consider it to be overly complicated and
perhaps a reduction of system security.
Please use Net::SSH or Expect along with the 'ssh' command instead.
HTH
--
Windows Vista and your freedom in conflict:
http://www.badvista.org/
------------------------------
Date: 7 Feb 2007 11:22:08 -0800
From: "CsB" <CSB001@gmail.com>
Subject: Re: Net::SSH::Perl - Channel open failure?
Message-Id: <1170876128.344884.71300@v45g2000cwv.googlegroups.com>
On Feb 6, 2:39 pm, "Mumia W. (NOSPAM)" <paduille.4060.mumia.w
+nos...@earthlink.net> wrote:
> Please use Net::SSH or Expect along with the 'ssh' command instead.
Thank you for your response.
The script I will eventually produce will replace one that currently
uses Net::Telnet. It accesses several thousand network components
(routers, switches, wireless access points, etc).
Please correct this if I am wrong, but if I use Net::SSH, I will need
to create and maintain a host key for each network component. This is
the primary reason I looked into Net::SSH:Perl first.
When you say to use "Expect along with the 'ssh' command instead",
would you be kind enough to provide a link to an example? I'm not
quite sure I understand your suggestion.
Also, I'm suprised I haven't received any additional responses. Do
you think I might have posted this in the wrong perl group?
Thank you again.
------------------------------
Date: Wed, 07 Feb 2007 17:49:49 -0600
From: "Mumia W. (NOSPAM)" <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Net::SSH::Perl - Channel open failure?
Message-Id: <eqdsql$j48$1@aioe.org>
On 02/07/2007 01:22 PM, CsB wrote:
> On Feb 6, 2:39 pm, "Mumia W. (NOSPAM)" <paduille.4060.mumia.w
> +nos...@earthlink.net> wrote:
>> Please use Net::SSH or Expect along with the 'ssh' command instead.
>
> Thank you for your response.
>
> The script I will eventually produce will replace one that currently
> uses Net::Telnet. It accesses several thousand network components
> (routers, switches, wireless access points, etc).
>
> Please correct this if I am wrong, but if I use Net::SSH, I will need
> to create and maintain a host key for each network component. This is
> the primary reason I looked into Net::SSH:Perl first.
>
I'm not an ssh or cryptography expert, but I think you would only need
to create the private and public keys on the machine doing the
accessing. The other machines would only need a copy of the public key
of the machine that will do the accessing. Read "man ssh-keygen."
> When you say to use "Expect along with the 'ssh' command instead",
> would you be kind enough to provide a link to an example? I'm not
> quite sure I understand your suggestion.
>
Expect.pm is a perl module that allows your program to interact with
other programs. You can use Expect to start the "ssh" utility and
programatically issue commands to ssh.
> Also, I'm suprised I haven't received any additional responses. Do
> you think I might have posted this in the wrong perl group?
>
> Thank you again.
>
You could also try comp.lang.perl.modules or alt.perl. A couple of weeks
ago, there was a discussion of Net::SSH::Perl in comp.lang.perl.modules.
HTH
--
Windows Vista and your freedom in conflict:
http://www.regdeveloper.co.uk/2006/10/29/microsoft_vista_eula_analysis/
------------------------------
Date: Thu, 08 Feb 2007 13:18:44 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Net::SSH::Perl - Channel open failure?
Message-Id: <cj8ms2p1n8teuebb9fk5usno4p5eamjh9g@4ax.com>
On 7 Feb 2007 11:22:08 -0800, "CsB" <CSB001@gmail.com> wrote:
>On Feb 6, 2:39 pm, "Mumia W. (NOSPAM)" <paduille.4060.mumia.w
>+nos...@earthlink.net> wrote:
>> Please use Net::SSH or Expect along with the 'ssh' command instead.
>
>Thank you for your response.
>
>The script I will eventually produce will replace one that currently
>uses Net::Telnet. It accesses several thousand network components
>(routers, switches, wireless access points, etc).
>
>Please correct this if I am wrong, but if I use Net::SSH, I will need
>to create and maintain a host key for each network component. This is
>the primary reason I looked into Net::SSH:Perl first.
>
>When you say to use "Expect along with the 'ssh' command instead",
>would you be kind enough to provide a link to an example? I'm not
>quite sure I understand your suggestion.
>
>Also, I'm suprised I haven't received any additional responses. Do
>you think I might have posted this in the wrong perl group?
>
>Thank you again.
You would be best off using the newer Net::SSH2
#!/usr/bin/perl
use warnings;
use strict;
use Net::SSH2;
use Data::Dumper;
# assuming a user named 'z' for demonstration
# connecting to localhost, so you need your sshd running
# see maillist archives at
# http://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users
# for deeper discussions
my $ssh2 = Net::SSH2->new();
#connect
$ssh2->connect('localhost') or die "Unable to connect Host $@ \n";
# authorize
# this works but I use keys below
# $ssh2->auth_password('z','zfoobar') or die "Unable to login $@ \n";
#this dosn't work
#$ssh2->auth(username=>'z', interact => 1);
#get the password for the key
use Term::ReadKey;
print "And your key password: ";
ReadMode('noecho');
chomp(my $pass = ReadLine(0));
ReadMode('restore');
print "\n";
$ssh2->auth_publickey('z',
'/home/z/.ssh/id_rsa.pub', #testing on localhost
'/home/z/.ssh/id_rsa',
$pass );
my $chan = $ssh2->channel();
$chan->exec('ls -la');
while (<$chan>){ print }
#will get dir named 2
my $chan1 = $ssh2->channel();
$chan1->exec('ls -la 2');
while (<$chan1>){ print }
# mkdir with sftp
my $sftp = $ssh2->sftp();
my $dir = '/home/z/3';
$sftp->mkdir($dir);
my %stat = $sftp->stat($dir);
print Dumper([\%stat]), "\n";
#put a file
my $remote = "$dir/".time;
$ssh2->scp_put($0, $remote);
#get a small file to a scalar
use IO::Scalar;
my $local = IO::Scalar->new; #it needs a blessed reference
$ssh2->scp_get($remote, $local);
print "$local\n\n";
#get a large file like a 100Meg wav file
my $remote1 = $dir.'/1.wav';
use IO::File;
my $local1 = IO::File->new("> 2.wav"); #it needs a blessed reference
$ssh2->scp_get($remote1, $local1);
# get a dirlist
my $dh = $sftp->opendir($dir);
while(my $item = $dh->read) {
print $item->{'name'},"\n";
}
#shell use
my $chan2 = $ssh2->channel();
$chan2->shell();
print $chan2 "uname -a\n";
print "LINE : $_" while <$chan2>;
print $chan2 "who\n";
print "LINE : $_" while <$chan2>;
$chan2->close;
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: 8 Feb 2007 05:32:18 -0800
From: "CsB" <CSB001@gmail.com>
Subject: Re: Net::SSH::Perl - Channel open failure?
Message-Id: <1170941538.899411.212460@a34g2000cwb.googlegroups.com>
On Feb 7, 5:49 pm, "Mumia W. (NOSPAM)"
>
>I think you would only need to create the private and public keys on the
>machine doing the accessing. ... Read "man ssh-keygen."
>
> You can use Expect to start the "ssh" utility and programatically issue
> commands to ssh.
>
> You could also try comp.lang.perl.modules or alt.perl. A couple of weeks
> ago, there was a discussion of Net::SSH::Perl in comp.lang.perl.modules.
>
Thank you again for your suggestions, I'll certainly take a look into
them.
------------------------------
Date: 8 Feb 2007 05:37:10 -0800
From: "CsB" <CSB001@gmail.com>
Subject: Re: Net::SSH::Perl - Channel open failure?
Message-Id: <1170941830.432022.249330@h3g2000cwc.googlegroups.com>
On Feb 8, 7:18 am, zentara <zent...@highstream.net> wrote:
>
> You would be best off using the newer Net::SSH2
>
Wow, I didn't know Net::SSH2 existed. Searching for SSH on cpan only
turned up the Net::SSH varieties. I will give it a try.
Also, thank you for the example code. It will certainly save me some
time.
------------------------------
Date: Thu, 08 Feb 2007 14:42:40 +0100
From: rahed <raherh@gmail.com>
Subject: Re: Net::SSH::Perl - Channel open failure?
Message-Id: <u4ppwpxyn.fsf@gmail.com>
"CsB" <CSB001@gmail.com> writes:
> Is there something special I need to do to utilize the existing open
> connection for subsequent commands? Or, am I way out in left-field on
> ths problem?
>
> Any suggestions or advice would be greatly appreciated.
>
> - - BEGIN - SCRIPT - - - - - - - -
>
> use Net::SSH::Perl;
> use strict;
> use warnings;
> my $host = "example.host.com";
> my $user = "username";
> my $password = "password";
> my $cmd = "ls";
> my $ssh = Net::SSH::Perl->new(
> $host,
> debug => 1,
> protocol => '2,1',
> port => 22
> );
> $ssh->login( $user, $password );
> $ssh->register_handler(
> "stdout",
> sub {
> my ( $channel, $buffer ) = @_;
> print "I received this: ", $buffer->bytes;
> }
> );
> $ssh->cmd($cmd);
I don't use register_handler method but you can run more commands with
cmd method like this (from docs) ($out,$err,$exit) = $ssh->cmd($cmd);
It's limited to ssh-2 protocol.
I run your code whithout problems. I think you should upgrade openSSH,
2.9 is quite outdated.
HTH
--
Radek
------------------------------
Date: Thu, 08 Feb 2007 14:54:13 +0100
From: rahed <raherh@gmail.com>
Subject: Re: Net::SSH::Perl - Channel open failure?
Message-Id: <uzm7ooiuy.fsf@gmail.com>
"Mumia W. (NOSPAM)" <paduille.4060.mumia.w+nospam@earthlink.net> writes:
> Maybe, maybe not. I advise against using Net::SSH::Perl. Others have
> noted it to be buggy, and I consider it to be overly complicated and
> perhaps a reduction of system security.
I use the module quite frequently and for my usage haven't noticed any
bugs. Complicated can be the installation because there are many
prerequisite modules.
--
Radek
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 112
**************************************