Thread: Re: [Ssh-sftp-perl-users] Anyone have an example of SSH2 to Cisco?
Brought to you by:
dbrobins
From: Matthew J. S. <vag...@ya...> - 2006-05-15 19:27:21
|
--- Mark Funk <mf...@tr...> wrote: > sub ssh2_cisco { > > my $ssh2 = Net::SSH2->new(); > > $ssh2->connect("$host1") or warn "Can't open > connection to $host1\n"; > > $ssh2->auth_password($user1, $pass1); > > my $chan = $ssh2->channel(); > > #$chan->pty('terminal'); > > $ssh2->exec('sh ver'); > > } > > > > root@tcpsyslog:/usr/local/scripts# ./ssh2.pl > > exec is not a valid Net::SSH2 macro at ./ssh2.pl > line 44 > > root@tcpsyslog:/usr/local/scripts# > > > > > > Thanks, Did you read the error message or just post it? "exec is not a valid Net::SSH2 macro at ./ssh2.pl line 44" Read the docs. There is no reference to exec. Your e-mail is not even asking a question! http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm Look at the given example. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Mark F. <mf...@tr...> - 2006-05-15 19:40:10
|
Did you read my subject? Or just post a response? I changed the line to this: sub ssh2_cisco { my $ssh2 =3D Net::SSH2->new(); $ssh2->connect("$host1") or warn "Can't open connection to $host1\n"; $ssh2->auth_password($user1, $pass1); my $chan =3D $ssh2->channel(); # using exec to execute a command $chan->exec('sh ver'); = <---------------------------------- print "EXEC : $_" while <$chan>; # don't forget to close since you can do only 1 exec $chan->close; # writing to a channel # a new channel, remember the last one is closed my $chan=3D$ssh2->channel(); $chan->shell(); print $chan "sh ver\n"; root@tcpsyslog:/usr/local/scripts# root@tcpsyslog:/usr/local/scripts# root@tcpsyslog:/usr/local/scripts# root@tcpsyslog:/usr/local/scripts# ./ssh2.pl Can't call method "exec" on = an undefined value at ./ssh2.pl line 44. root@tcpsyslog:/usr/local/scripts# But I still get an error............ >Read the docs. There is no reference to exec. Your >e-mail is not even asking a question! >http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm >Look at the given example. Also, the doc reference you replied back with is for SSH not SSH2! David M. Funk President/CEO =A0 Tivoli Certified Enterprise Consultant Specializing in Network and Systems Management Solutions Trinity Solutions=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 604 Cassandra Dr.=A0=A0=A0=A0=A0=A0=A0=20 Cranberry Twp., PA 16066 =A0 Phone: = 724-316-0721=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 Fax:=A0=A0=A0 724-772-7889=20 email: mf...@tr... http://www.trinitysol.net -----Original Message----- From: Matthew J. Salerno [mailto:vag...@ya...]=20 Sent: Monday, May 15, 2006 3:27 PM To: Mark Funk; ssh...@li... Subject: Re: [Ssh-sftp-perl-users] Anyone have an example of SSH2 to = Cisco? --- Mark Funk <mf...@tr...> wrote: > sub ssh2_cisco { >=20 > my $ssh2 =3D Net::SSH2->new(); >=20 > $ssh2->connect("$host1") or warn "Can't open > connection to $host1\n"; >=20 > $ssh2->auth_password($user1, $pass1); >=20 > my $chan =3D $ssh2->channel(); >=20 > #$chan->pty('terminal'); >=20 > $ssh2->exec('sh ver'); >=20 > } >=20 > =20 >=20 > root@tcpsyslog:/usr/local/scripts# ./ssh2.pl >=20 > exec is not a valid Net::SSH2 macro at ./ssh2.pl > line 44 >=20 > root@tcpsyslog:/usr/local/scripts# >=20 > =20 >=20 > =20 >=20 > Thanks, Did you read the error message or just post it? "exec is not a valid Net::SSH2 macro at ./ssh2.pl line 44" Read the docs. There is no reference to exec. Your e-mail is not even asking a question! http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm Look at the given example. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around=20 http://mail.yahoo.com=20 |
From: Matthew J. S. <vag...@ya...> - 2006-05-15 20:30:55
|
--- Mark Funk <mf...@tr...> wrote: > Did you read my subject? Or just post a response? > > I changed the line to this: > sub ssh2_cisco { > my $ssh2 = Net::SSH2->new(); > $ssh2->connect("$host1") or warn "Can't open > connection to $host1\n"; > $ssh2->auth_password($user1, $pass1); > my $chan = $ssh2->channel(); > # using exec to execute a command > $chan->exec('sh ver'); > <---------------------------------- > print "EXEC : $_" while <$chan>; > > # don't forget to close since you can do only 1 > exec > $chan->close; > # writing to a channel > # a new channel, remember the last one is closed > my $chan=$ssh2->channel(); > $chan->shell(); > print $chan "sh ver\n"; > > > root@tcpsyslog:/usr/local/scripts# > root@tcpsyslog:/usr/local/scripts# > root@tcpsyslog:/usr/local/scripts# > root@tcpsyslog:/usr/local/scripts# ./ssh2.pl Can't > call method "exec" on an > undefined value at ./ssh2.pl line 44. > root@tcpsyslog:/usr/local/scripts# > > But I still get an error............ > > > >Read the docs. There is no reference to exec. > Your > >e-mail is not even asking a question! > > >http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm > > >Look at the given example. > > > Also, the doc reference you replied back with is for > SSH not SSH2! > > > > David M. Funk > President/CEO > � > > > -----Original Message----- > From: Matthew J. Salerno > [mailto:vag...@ya...] > Sent: Monday, May 15, 2006 3:27 PM > To: Mark Funk; > ssh...@li... > Subject: Re: [Ssh-sftp-perl-users] Anyone have an > example of SSH2 to Cisco? > > --- Mark Funk <mf...@tr...> wrote: > > > sub ssh2_cisco { > > > > my $ssh2 = Net::SSH2->new(); > > > > $ssh2->connect("$host1") or warn "Can't open > > connection to $host1\n"; > > > > $ssh2->auth_password($user1, $pass1); > > > > my $chan = $ssh2->channel(); > > > > #$chan->pty('terminal'); > > > > $ssh2->exec('sh ver'); > > > > } > > > > > > > > root@tcpsyslog:/usr/local/scripts# ./ssh2.pl > > > > exec is not a valid Net::SSH2 macro at ./ssh2.pl > > line 44 > > > > root@tcpsyslog:/usr/local/scripts# > > > > > > > > > > > > Thanks, > > Did you read the error message or just post it? > > "exec is not a valid Net::SSH2 macro at ./ssh2.pl > line > 44" > > Read the docs. There is no reference to exec. Your > e-mail is not even asking a question! > > http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm > > Look at the given example. > > __________________________________________________ I have to admit, I just skimmed the subject and read the body, which is where most people post their questions. I would recommend looking at the source code and mailing list archives. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Eric L. <net...@er...> - 2006-05-17 00:42:22
|
> Behalf Of Matthew J. Salerno > Did you read the error message or just post it? > > "exec is not a valid Net::SSH2 macro at ./ssh2.pl line 44" > > Read the docs. There is no reference to exec. Your e-mail > is not even asking a question! > > http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm > > Look at the given example. Matthew, The actual Link should be http://search.cpan.org/~dbrobins/Net-SSH2-0.08/lib/Net/SSH2.pm since Mark is trying to work with Net::SSH2, not Net::SSH::Perl. Mark is trying to use the new module. Mark, The problem with your script is that you are calling execute on the ssh2 object and not the channel object. Changing this: my $chan = $ssh2->channel(); $ssh2->exec('sh ver'); To this: my $chan = $ssh2->channel(); $chan->exec('sh ver'); Should take care of the problem with the invalid macro. Hope this helps. |