Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: New to Perl

by Utilitarian (Vicar)
on Nov 18, 2010 at 13:38 UTC ( #872244=note: print w/ replies, xml ) Need Help??


in reply to New to Perl

Not sure if I understand your request correctly, however nmap returns a list of network services for each host on a given segment.

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."


Comment on Re: New to Perl
Download Code
Re^2: New to Perl
by NastyPenguin (Initiate) on Nov 21, 2010 at 09:52 UTC
    SO i've kinda got though the first part now I need to ping from the first entered address through to the last entered address. here is the code i have so far
    #A script to identify any device that is using factory settings within + the network ie default username and password. #The script is designed so that the user (Network Admin) enters in bot +h the start and end of the IP range of the network and a address list + #is then generated and logged.After logging the range of the network e +ach address will be pinged to detect if a device is located on that a +ddress #A second log file is created and the active address are then listed. +On a second round the script will grab any information the device is #showing and log this as well. The known device locatations are then t +o be cross referenced with a default list of device usernames and pas +swords. #If a device is able to be access with one of the defaults it will be +listed as TRUE in the log and the device will be identified as well. #Once complete an email will be sent to the admin containing the three + log files. #!/usr/bin/perl -w use strict; use warnings; use diagnostics; #Enter and Validate IP Address Range. use Data::Validate::IP qw(is_ipv4 is_ipv6); print "Enter IP Range Starting Address:"; my $answera = <STDIN>; if(is_ipv4($answera)){ print "Looks like an ipv4 address\n"; } else { print "Not an ipv4 address\n"; print "\nReEnter Address:"; my $answera = <STDIN>; } print "\nEnter IP Range Finishing Address:"; my $answerb = <STDIN>; if(is_ipv4($answerb)){ print "Looks like an ipv4 address"; } else { print "Not an ipv4 address\n"; print "\nReEnter Address:\n"; my $answerb = <STDIN>; } use Net::IP; use NetAddr::IP; my $ipa = new NetAddr::IP->new($answera); my $ipb = new NetAddr::IP->new($answerb); print "\nNetwork starts at $ipa and finshes at $ipb\n"; #Create a log file with the active IP address and corresponding device + names. open (MYLOG, '>>addressrange.txt'); print MYLOG "Network starts at $ipa and finshes at $ipb"; print MYLOG "$ipa +(1)"; close (MYLOG); #Create range between the two entered IP address' #Ping address' within the range. Log these in the log file. use Net::Ping; my $p = Net::Ping->new(); $p->ping($ipa [,5]); print "$ipa ia alive.\n" if $p->ping($ipa); $p->close();
    I've read the syntax and diagnostics but it's not making any sense sorry.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://872244]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2015-07-07 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls