467,202 Members | 1,114 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,202 developers. It's quick & easy.

Threads, Need help

I 've got this script here and struggling to apply threads to the "ping" part of the program, Any help much appreciated.
Expand|Select|Wrap|Line Numbers
  1. use Net::Ping;
  2. use Getopt::Std;
  3.  
  4. sub usage
  5. {
  6. print "pingscan -f <Input file> -o <Output file>";
  7. exit 0;
  8. }
  9.  
  10. my %options;
  11. getopts('f:o:',\%options) || die usage();
  12.  
  13. usage() if!($options{'f'});
  14. usage() if!($options{'o'});
  15.  
  16. $p = Net::Ping->new("icmp");
  17.  
  18. if($options{'f'}){
  19. $ipfile = $options{'f'};
  20. }
  21.  
  22. if($options{'o'}){
  23. $opfile = $options{'o'};
  24. }
  25.  
  26. chomp($ipfile);
  27. open I,"<$ipfile" || die ("cannot open file");
  28. @host = <I>;
  29.  
  30. chomp($opfile);
  31.  
  32. open P,">>$opfile" || die ("cannot create output file");
  33.  
  34. foreach (@host){
  35. print P $_ if $p->ping($_, 2);
  36. }
Jul 15 '08 #1
  • viewed: 1016
Share:
1 Reply
numberwhun
Expert Mod 2GB
Although I am experiencing some issues in adding the code tags to your posting, you really need to use them when adding code to your posts.

Regards,

Jeff
Jul 16 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by andrewpalumbo@hotmail.com | last post: by
6 posts views Thread by Simon Harvey | last post: by
34 posts views Thread by Kovan Akrei | last post: by
22 posts views Thread by Jeff Louie | last post: by
6 posts views Thread by RahimAsif@hotmail.com | last post: by
3 posts views Thread by michdoh@yahoo.com | last post: by
9 posts views Thread by jdlists@gmail.com | last post: by
9 posts views Thread by koschwitz@gmx.de | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.