#!/usr/bin/perl -w use lib '/enm01/custom/scripts/modules'; use Expect; use cisco qw(&login_auth);; my $exp = new Expect; # Parces the BASH arugments into Perl variables ( $UNAME, $PWD, $ENABLE, $DNAME, $IP, $LOG ) = @ARGV; # This logs in and authenticates to the device login_auth(@ARGV); # This checks to make sure the hostname is correct namecheck(); sub namecheck { if ( $DNAME !~ /U....WX[0-9][0-9]/ ) { $exp->send("show run | include hostname\n"); @hostintval = $exp->expect( 10,"#"); $newmatch = $hostintval[3]; @hostname = split(m[ |\n],$newmatch); foreach(@hostname) { if ( ($_ !~ m/^hostname$|^show$|^run$|\||^include$|^$|\cM$/) ) { if ( $DNAME ne $_ ) { print LOG "$DNAME" . " is incorrect please change to " . "$_\n"; $DNAME = $_; } } } } }