By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,661 Members | 1,330 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,661 IT Pros & Developers. It's quick & easy.

Threads, Need help

P: 23
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
Share this Question
Share on Google+
1 Reply


numberwhun
Expert Mod 2.5K+
P: 3,503
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.