Null_Route0 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use warnings; use 5.010; ###prompt for host### print "Host IP "; my $host = <>; ##Setup connection### use Net::SSH::Perl; my $ssh = Net::SSH::Perl->new($host); $ssh->login('user', 'pw'); ###run commands### my($run) = $ssh->cmd("show run"); ##create file and write to it### my $filename = $host; open(my $fh, '>', $filename) or die "Could not open file '$filename' $ +!"; say $fh ($run); close $fh; say 'done'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Script to enable Cisco
by aitap (Curate) on Jul 23, 2012 at 16:04 UTC | |
by Null_Route0 (Initiate) on Jul 23, 2012 at 17:12 UTC | |
by dasgar (Priest) on Jul 23, 2012 at 18:13 UTC | |
by Null_Route0 (Initiate) on Jul 23, 2012 at 18:17 UTC | |
by aitap (Curate) on Jul 23, 2012 at 17:33 UTC | |
by Null_Route0 (Initiate) on Jul 23, 2012 at 18:05 UTC | |
by aitap (Curate) on Jul 23, 2012 at 18:12 UTC | |
|
Re: Perl Script to enable Cisco
by i5513 (Pilgrim) on Jul 23, 2012 at 18:30 UTC | |
by Null_Route0 (Initiate) on Jul 23, 2012 at 18:40 UTC |