Hi,

  As per you suggestion i removed the last line of the code  and the
replaced with the code, now the code looks like this
--------------------------------------------------------------------------------------

#!/usr/bin/perl -w
  use strict;
  use Net::SSH2;

  my $ssh2 = Net::SSH2->new();
  $ssh2->connect('sys5') or die "Unable to connect host $@ \n";
  $ssh2->auth_password('xyz','mypass');
  my $chan = $ssh2->channel();
  $chan->exec('ls -la');
  while (<$chan>) {print}
   my $buflen = 10000;
   my $buf1 = '0' x $buflen;
   $chan->read($buf1, $buflen);
    print "BUF1:\n", $buf1,"\n";
------------------------------------------------------------------------------

The problem is when i run this script i'm getting this error after about
60-70 seconds  "Can't call method "exec" on an undefined value at
C:\perl_scripts\ssh2.pl line 1
0.
Press any key to continue . . ."

Kindly let me know if i didn't anything wrong.....please help me with this
and it wud great if u can provide me with link which can give the solution



Thanks,
Monnappa






On Thu, Nov 20, 2008 at 4:23 PM, sisyphus <[EMAIL PROTECTED]> wrote:

>
>
> Monnappa Appaiah wrote:
>
> .
> .
> >
> ----------------------------------------------------------------------------
> > 1)
> >
> >  #!/usr/bin/perl -w
> > use strict;
> > use Net::SSH2;
> >
> > my $ssh2 = Net::SSH2->new();
> > $ssh2->connect('sys5') or die "Unable to connect host $@ \n";
> > $ssh2->auth_password('xyz','mypass');
> > my $chan = $ssh2->channel();
> > $chan->exec('ls -la');
> > while (<$chan>) {print}
> >
> -------------------------------------------------------------------------------------
>
> The trouble is that, on Windows, the "<$chan>" doesn't work. Try
> removing that last line of your code, and replace it with:
>
> --------------------------------
> my $buflen = 10000;
> my $buf1 = '0' x $buflen;
>
> $chan->read($buf1, $buflen);
> print "BUF1:\n", $buf1, "\n";
> --------------------------------
>
> That works for me. If the buffer needs to be bigger just increase
> $buflen accordingly.
>
> Cheers,
> Rob
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

Reply via email to